3
votes

Below given is my code:

SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchQuery("field", "value to search"));
Search search = new Search.Builder(searchSourceBuilder.toString()).build();
JestResult result = jestc.execute(search);

While running this code it gives exception: {"error":{"root_cause":[{"type":"parsing_exception","reason":"[match] query does not support [auto_generate_synonyms_phrase_query]","line":1,"col":213}],"type":"parsing_exception","reason":"[match] query does not support [auto_generate_synonyms_phrase_query]","line":1,"col":213},"status":400}

Need help to resolve this issue.... Tried match_all query and it worked. No idea why this is failing.

I am using "org.elasticsearch" and "org.elasticsearch.client" of 6.1.1 version and jest version is 5.3.3. Not sure if it matters.

Thanks in advance

1

1 Answers

19
votes

Found the problem. I was using the 6.1.1 API version, but my elastic nodes were on 5.x which doesn't support the auto_generate_synonyms_phrase_query parameter.

I moved "org.elasticsearch" and "org.elasticsearch.client" to version 5.6.0 and this fixed it for me. There are certain methods such as QueryBuilders.matchQuery(...) in the 6.1.1 client that add the new parameter and hence break backwards compatibility. The elasticsearch nodes where I am performing the query are on 5.x so they don't understand this new parameter.