Yokozuna solr schema file enum support

213 Views Asked by At

In our solr schema file, we are defining enum field types and specifying an external enums.xml file in the enumConfig parameter.

However, we have to manually copy that file to the /conf directory of the search index we’re creating or updating.

Is there a way to do it programmatically using the riak java client? The Yokozuna index classes in the API don’t seem to support external file loading so it complains that it can't find the enums.xml file in the path. We want to be able to update the schema programmatically and point to the enums.xml file so that we can update the search index without having to copy the enums.xml file manually to the /conf directory.

2

There are 2 best solutions below

2
On BEST ANSWER

There is currently no functionality in the API accessible via the Java client that would allow you to upload an external file like enums.xml. For now you would have to manually copy the file to each node in your cluster.

2
On

This will create a schema (and its XML file) on your Riak cluster:

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);

Then you can create an index based on that schema:

String indexName = "enum_idx";

YokozunaIndex indexObj = new YokozunaIndex(indexName, schemaName);
StoreIndex storeIndex = new StoreIndex.Builder(indexObj).build();
client.execute(storeIndex);

Riak client for Java 2.x