Elasticsearch 2.1.1 -DFS_QUERY_THEN_FETCH - how to get most recent doc

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();

What does the documents look like? Do you they have a timestamp that helps you determine which one is the latest?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.