Dfs_query_then_fetch value not working with SearchRequestBuilder.setSearchType

I implemented an ActionPlugin by extending BaseRestHandler. But when I set the searchType (searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH).execute().get()....) it isn't being honored. I can tell the DFS_QUERY_THEN_FETCH isn't working because the scoring is different with the same query executed twice.

Using the REST api externally (via curl) works:
GET /product/_search?search_type=dfs_query_then_fetch ...

Using ElasticSearch 6.1.0.
The index has two replicas.
{
"cluster_name": "stage-1",
"status": "green",
"timed_out": false,
"number_of_nodes": 2,
"number_of_data_nodes": 2,
"active_primary_shards": 10,
"active_shards": 20,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100,
"indices": {
"product_index.json": {
"status": "green",
"number_of_shards": 5,
"number_of_replicas": 1,
"active_primary_shards": 5,
"active_shards": 10,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
},
"product": {
"status": "green",
"number_of_shards": 5,
"number_of_replicas": 1,
"active_primary_shards": 5,
"active_shards": 10,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
}
}
}

Maybe DFS_QUERY_THEN_FETCH option on searchRequestBuilder is being honored. It's just not working the way I initially understood.

I ended up using preference parameter, and that seems to make queries repeatable in terms of scoring and result order.

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