From d986a834fcaf5535a90c10a6b34de1584d0c9a8b Mon Sep 17 00:00:00 2001 From: Christine Poerschke Date: Wed, 24 Jul 2024 16:47:32 +0100 Subject: [PATCH] SOLR-13350, SOLR-17298: multi-threaded search: don't (yet) support query limits --- .../apache/solr/search/MultiThreadedSearcher.java | 4 +++- .../org/apache/solr/search/SolrIndexSearcher.java | 6 ++++-- .../org/apache/solr/search/TestCpuAllowedLimit.java | 8 ++------ .../test/org/apache/solr/search/TestQueryLimits.java | 12 +----------- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/search/MultiThreadedSearcher.java b/solr/core/src/java/org/apache/solr/search/MultiThreadedSearcher.java index f9810b1a083..0c825b415ce 100644 --- a/solr/core/src/java/org/apache/solr/search/MultiThreadedSearcher.java +++ b/solr/core/src/java/org/apache/solr/search/MultiThreadedSearcher.java @@ -119,8 +119,10 @@ SearchResult searchCollectorManagers( return new SearchResult(scoreMode, ret); } - static boolean allowMT(DelegatingCollector postFilter, QueryCommand cmd, Query query) { + static boolean allowMT( + DelegatingCollector postFilter, boolean queryLimitsEnabled, QueryCommand cmd, Query query) { if (postFilter != null + || queryLimitsEnabled || cmd.getSegmentTerminateEarly() || cmd.getTimeAllowed() > 0 || !cmd.getMultiThreaded()) { diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java index 8204487fed3..07f49c5b463 100644 --- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java +++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java @@ -1920,7 +1920,8 @@ public ScoreMode scoreMode() { } final TopDocs topDocs; final ScoreMode scoreModeUsed; - if (!MultiThreadedSearcher.allowMT(pf.postFilter, cmd, query)) { + if (!MultiThreadedSearcher.allowMT( + pf.postFilter, QueryLimits.getCurrentLimits().isLimitsEnabled(), cmd, query)) { if (log.isDebugEnabled()) { log.debug("skipping collector manager"); } @@ -2045,7 +2046,8 @@ public ScoreMode scoreMode() { qr.setNextCursorMark(cmd.getCursorMark()); } else { final TopDocs topDocs; - if (!MultiThreadedSearcher.allowMT(pf.postFilter, cmd, query)) { + if (!MultiThreadedSearcher.allowMT( + pf.postFilter, QueryLimits.getCurrentLimits().isLimitsEnabled(), cmd, query)) { @SuppressWarnings({"rawtypes"}) final TopDocsCollector topCollector = buildTopDocsCollector(len, cmd); final DocSetCollector setCollector = new DocSetCollector(maxDoc); diff --git a/solr/core/src/test/org/apache/solr/search/TestCpuAllowedLimit.java b/solr/core/src/test/org/apache/solr/search/TestCpuAllowedLimit.java index ea02e448da8..dac4ec5124c 100644 --- a/solr/core/src/test/org/apache/solr/search/TestCpuAllowedLimit.java +++ b/solr/core/src/test/org/apache/solr/search/TestCpuAllowedLimit.java @@ -185,9 +185,7 @@ public void testDistribLimit() throws Exception { "stages", "prepare,process", "cpuAllowed", - "50", - "multiThreaded", - "false")); + "50")); // System.err.println("rsp=" + rsp.jsonStr()); assertNotNull("should have partial results", rsp.getHeader().get("partialResults")); @@ -206,9 +204,7 @@ public void testDistribLimit() throws Exception { "stages", "prepare,process", "cpuAllowed", - "50", - "multiThreaded", - "false")); + "50")); // System.err.println("rsp=" + rsp.jsonStr()); assertNotNull("should have partial results", rsp.getHeader().get("partialResults")); } diff --git a/solr/core/src/test/org/apache/solr/search/TestQueryLimits.java b/solr/core/src/test/org/apache/solr/search/TestQueryLimits.java index ae1b0a32d6c..6e413f6bfd2 100644 --- a/solr/core/src/test/org/apache/solr/search/TestQueryLimits.java +++ b/solr/core/src/test/org/apache/solr/search/TestQueryLimits.java @@ -76,17 +76,7 @@ public void testQueryLimits() throws Exception { rsp = solrClient.query( COLLECTION, - params( - "q", - "id:*", - "sort", - "id asc", - "facet", - "true", - "facet.field", - "val_i", - "multiThreaded", - "false")); + params("q", "id:*", "sort", "id asc", "facet", "true", "facet.field", "val_i")); assertNotNull( "should have partial results for expr " + matchingExpr, rsp.getHeader().get("partialResults"));