I am trying to make an Elasticsearch search with Java and Elasticsearch. Elastic search provides API for Java and this is cool.
The thing is, I wish to create a method in Java who receives a string (properly, a JSON containing information for searching) who reflects this HTTP call to Elasticsearch
curl -X GET 'http://localhost:9200/geocon/_search?q=first:"Sonya"'
But I want this method as much general as possible.
So the question is: is it possible to parse and translate 1:1 HTTP request to Elasticsearch with Java API? Maybe giving to the Elasticsearch object just the JSON string as parameter?
Check this out. Maybe this post can help you:
How to construct QueryBuilder from JSON DSL when using Java API in ElasticSearch?
Basically you need to do something like this:
String query = whatever_query...
SearchResponse response = esClient.prepareSearch(Configuration.PRIMARY_INDEX_NAME)
.setQuery(query)
.execute()
.actionGet();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With