We are using ES version 2.1.1 and below code not returning the latest document created. Please suggest and let me know if the DFS_QUERY_THEN_FETCH is good idea to use in prod ?
we lookup the given input in ES by using below code and then updates some of the other attributes associated to that found document in ES
Example : this code returns Dave Deleted but expecting Dave Created document since Created document is the latest entry in ES.
Name | Status
Dave Deleted
Dave Created
final SearchRequestBuilder srb = es.getClient().prepareSearch(es.getStatsIndex()).setTypes("voiceProductSnapshot")
.setSearchType(org.elasticsearch.action.search.SearchType.DFS_QUERY_THEN_FETCH);
final BoolQueryBuilder qb = QueryBuilders.boolQuery();
qb.must(QueryBuilders.termQuery("sortName", zoneName));
final SearchResponse response = srb.setQuery(qb).execute().actionGet();