We have been using ES 5.2, and java API with TransportClient. The use case is, our users select an index, and input a JSON query. We use this query with SearchTemplateRequestBuilder to get the response. The code looks like this.
SearchTemplateResponse response =
new SearchTemplateRequestBuilder(esclient)
.setRequest(searchRequest)
.setScript(query)
.setScriptType(ScriptType.INLINE)
.get();
And then we parse response, and create our own handlers for hits/aggregations. Now we intend to upgrade to 6.2 and replace TransportClient with reset client, because of obvious reasons that it is going to die. The high level rest client looks most appropriate, since we can apparently re-use most of our code, but I couldn't find a way to fire a search query using JSON string I have. Would be great if we can get some help with this problem.
The search template API is not yet supported by the high-level REST client. If you need to send a query as a string though, you can do so using the low-level REST client. Though that way you also need to parse back the response yourself.
Otherwise WrapperQueryBuilder may help you when it comes to providing a query in json string, but that's only for the query section of a search request.
Thank you Luca for your reply, the json query is entered by the users, so we can't go with limiting it to query section only. And this would mean effectively I can't use hight-level REST client yet. Could you please let me know when is the expected release date for ES 7 and 8, just wanted to check how much time we have to live with transport client.
I see. Search templates API is in our list of the API that we need to add to the high-level REST client. We will have that certainly before we remove the transport client. We don't have dates set for our future major releases. Quite some things to get done on our end before 7.0 I would say.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.