0

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 Answers2

0

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

vempo
  • 3,093
  • 1
  • 14
  • 16
  • I wouldn't need to create an index for the enums.xml file I believe since it's only referenced through the main solr schema. However, if I just store it as noted in your answer, would it be copied to the /conf directory? – Tarun Sukhani Aug 14 '15 at 15:28
  • Sorry, I misunderstood your question. This code is for uploading a complete schema, not an enumsConfig. – vempo Aug 16 '15 at 07:38
0

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.

Craig
  • 1,001
  • 6
  • 11
  • Thanks Craig. Any idea when this functionality would be added? – Tarun Sukhani Aug 16 '15 at 03:01
  • Tarun, I don't know if or when that feature will be added. The code base is located at https://github.com/basho/yokozuna on Github. If this is a feature you are interested in you can certainly submit an issue. If you are interested in adding the functionality you can also submit a pull request. – Craig Aug 17 '15 at 15:29