Set custom analyzer with Java API

(Zoltan Toth) #1

Hi There!

I'm building a Java Map with a content like this as I'd like to set a custom analyzer:

{index={analysis={analyzer=[{whitespace_lowercase={filter=whitespace , type=custom, tokenizer=whitespace }}]}}}

But when I try to create the index with this map like this:

CreateIndexRequestBuilder createIndexRequestBuilder = elasticClient.admin().indices().prepareCreate("test");

CreateIndexResponse resp = createIndexRequestBuilder.setSettings(theJavaMap).execute().actionGet();

Then I get an error:

java.lang.IllegalArgumentException: Analyzer [0] must have a type associated with it

Does anyone have an idea how the hell should I make this work? Does elastic search has a better programmatic API than json building/map for creating analyzers?


PS: I'm using elastic 2.x.x beta

(Zoltan Toth) #2

Eventually I found the solution. The problem was that the analyzer field contained an array of objects, however that must be strictly an object.

(system) #3