From a8131b9e82a86c941e226f4c8f84d04b7dad8521 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Tue, 11 Jun 2024 16:03:37 +0100 Subject: [PATCH] clarify pre filter shard size --- .../action/search/TransportSearchAction.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java b/server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java index 4ff1e660698a6..84ef35e017d66 100644 --- a/server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java +++ b/server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java @@ -482,9 +482,6 @@ void executeRequest( OpenPointInTimeRequest pitReq = new OpenPointInTimeRequest(searchRequest.indices()).indicesOptions( searchRequest.indicesOptions() ).preference(searchRequest.preference()).routing(searchRequest.routing()).keepAlive(TimeValue.ONE_MINUTE); - - // The can match phase can reorder shards, so we disable it to ensure the stable ordering - searchRequest.setPreFilterShardSize(Integer.MAX_VALUE); nodeClient.execute(TransportOpenPointInTimeAction.TYPE, pitReq, new ActionListener<>() { @Override public void onResponse(OpenPointInTimeResponse resp) { @@ -504,6 +501,11 @@ public void onFailure(Exception e) { }); return; } + if (retriever.isCompound()) { + // The can match phase can reorder shards, so we disable it to ensure the stable ordering + // when running multiple requests within the same pit. + searchRequest.setPreFilterShardSize(Integer.MAX_VALUE); + } Rewriteable.rewriteAndFetch( searchRequest, searchService.getRewriteContext(timeProvider::absoluteStartMillis, resolvedIndices, searchRequest.pointInTimeBuilder()),