I am new to ElasticSearch and have been trying to write Java EE to bring data in from an Informal DB and then run user searches on it. I have been able to get the indexing to work and am able to retrieve a specific indexed document via 'GET /index/type/id' type structure, but when I try to search for a string I get various errors. Currently, I am running on a local instance of ElasticSearch ver6.0.0 on my MacBook Pro. I also have a local instance of Kibana running and am able to retrieve data within it.
My code looks like this:
public SearchResponse searchRecord(String searchString ) throws RadarException {
SearchRequest searchRequest = new SearchRequest();
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.queryStringQuery(searchString)
.lenient(Boolean.TRUE)
.autoGenerateSynonymsPhraseQuery(Boolean.FALSE));
searchRequest.source(searchSourceBuilder);
searchRequest.types("njcrash"); //put in to see if specifying a type would fix error when type was not specifed
SearchResponse searchResponse;
try {
searchResponse = restClient.search(searchRequest);
} catch (Throwable t) {
throw new RadarException("Search faild: " + searchRequest.source().toString(), t);
}
I get the following error (just a segment from the stack dump):
[type=parsing_exception, reason=[query_string] query does not support [auto_generate_synonyms_phrase_query]]]
The following is the generated search string that was executed ('searchRequest.source()'):
{"query":{"query_string":{"query":"JULIE","fields":[],"type":"best_fields","default_operator":"or","max_determinized_states":10000,"enable_position_increments":true,"fuzziness":"AUTO","fuzzy_prefix_length":0,"fuzzy_max_expansions":50,"phrase_slop":0,"lenient":true,"escape":false,"auto_generate_synonyms_phrase_query":false,"fuzzy_transpositions":true,"boost":1.0}}}
My problem/question is .. How do I get the QueryBuilders.queryStringQuery(string) to STOP inserting the 'auto_generate_sysnonyms_phrase_query' parameter since query_string doesn't support it?
Oh, I just noticed the code segment was from after I tried making the auto_generate_synonyms_phrase_query false... prior to this the parameter was NOT present in the code and it added it anyways set to TRUE.
Dan