I have following requirements in my spring web app:
I've written search with Java API using SearchRequestBuilder and it works fine:
SearchRequestBuilder request = client.prepareSearch("index").setTypes("type")
.setSearchType(SearchType.QUERY_THEN_FETCH).setFrom(0).setSize(10).addFields(RESPONSE_FIELDS);
//request is much more complicated
//...
SearchResponse response = request.execute().actionGet();
SearchHits hits = response.getHits();
But for displaying it on google map i would prefer to just get JSON object from elasticsearch instead of SearchResponse object like this:
{
"_index": "indexName",
"_type": "type",
"_id": "9094",
"_version": 31,
"found": true,
"_source": {
//list of properties
}
}
Is it possible to get JSON response using Java API + SearchRequestBuilder or i have to use REST API for that?
The Java api will not map to json (or any other entity for that matter) for you. However, you could do something like:
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