Skip to content

Commit

Permalink
CCS: Disable minimizing round-trips when dfs is requested (elastic#40044
Browse files Browse the repository at this point in the history
)

When using DFS_QUERY_THEN_FETCH search type, the dfs phase is run and
its results are used in the query phase to make scoring accurate.
When using CCS, depending on whether the DFS phase runs in the CCS
coordinating node (like if all shards were local) or in each remote
cluster (when minimizing round-trips), scoring will differ.

This commit disables minimizing round-trips whenever DFS is requested,
as it is not currently  possible to ensure that scoring is accurate in
that case.

Relates to elastic#32125
  • Loading branch information
javanna committed Mar 19, 2019
1 parent cb29d3d commit 0733523
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -80,6 +80,7 @@
import java.util.function.Function;
import java.util.function.LongSupplier;

import static org.elasticsearch.action.search.SearchType.DFS_QUERY_THEN_FETCH;
import static org.elasticsearch.action.search.SearchType.QUERY_THEN_FETCH;

public class TransportSearchAction extends HandledTransportAction<SearchRequest, SearchResponse> {
Expand Down Expand Up @@ -248,6 +249,9 @@ static boolean shouldMinimizeRoundtrips(SearchRequest searchRequest) {
if (searchRequest.scroll() != null) {
return false;
}
if (searchRequest.searchType() == DFS_QUERY_THEN_FETCH) {
return false;
}
SearchSourceBuilder source = searchRequest.source();
return source == null || source.collapse() == null || source.collapse().getInnerHits() == null ||
source.collapse().getInnerHits().isEmpty();
Expand Down
Expand Up @@ -812,6 +812,11 @@ public void testShouldMinimizeRoundtrips() throws Exception {
collapseBuilder.setInnerHits(new InnerHitBuilder("inner"));
assertFalse(TransportSearchAction.shouldMinimizeRoundtrips(searchRequest));
}
{
SearchRequest searchRequest = new SearchRequest();
searchRequest.searchType(SearchType.DFS_QUERY_THEN_FETCH);
assertFalse(TransportSearchAction.shouldMinimizeRoundtrips(searchRequest));
}
{
SearchRequestTests searchRequestTests = new SearchRequestTests();
searchRequestTests.setUp();
Expand Down

0 comments on commit 0733523

Please sign in to comment.