这将在您的 Riak 集群上创建一个模式(及其 XML 文件):
import com.basho.riak.client.api.RiakClient;
import com.basho.riak.client.api.commands.search.*;
import com.basho.riak.client.core.query.search.YokozunaIndex;
import com.basho.riak.client.core.query.search.YokozunaSchema;
String schemaName = "enum";
RiakClient client = RiakClient.newClient("127.0.0.1");
String schemaStr = ...; // read from local enum.xml
YokozunaSchema schemaObj = new YokozunaSchema(schemaName, schemaStr);
StoreSchema storeSchema = new StoreSchema.Builder(schemaObj).build();
client.execute(storeSchema);
然后,您可以基于该架构创建索引:
String indexName = "enum_idx";
YokozunaIndex indexObj = new YokozunaIndex(indexName, schemaName);
StoreIndex storeIndex = new StoreIndex.Builder(indexObj).build();
client.execute(storeIndex);
用于 Java 2.x 的 Riak 客户端