This is an automated email from the ASF dual-hosted git repository. dsmiley pushed a commit to branch branch_9x in repository https://gitbox.apache.org/repos/asf/solr.git
commit 7a002a5ba8a6f1dd6d20fc08718800754739b554 Author: Jan Høydahl <[email protected]> AuthorDate: Fri Jun 5 00:57:51 2026 +0200 DistributedCombinedQueryComponentTest hangs in nightly (#4497) (cherry picked from commit de1e74298fa1e99eaf9a6802386c97da0789aee9) --- .../DistributedCombinedQueryComponentTest.java | 109 ++++++++++----------- 1 file changed, 53 insertions(+), 56 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedCombinedQueryComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedCombinedQueryComponentTest.java index dc586ebf17b..e6b2805236f 100644 --- a/solr/core/src/test/org/apache/solr/handler/component/DistributedCombinedQueryComponentTest.java +++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedCombinedQueryComponentTest.java @@ -60,9 +60,8 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch * * @throws Exception if any error occurs during the indexing process. */ - private synchronized void prepareIndexDocs() throws Exception { + private void prepareIndexDocs() throws Exception { List<SolrInputDocument> docs = new ArrayList<>(); - fixShardCount(2); for (int i = 1; i <= NUM_DOCS; i++) { SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", Integer.toString(i)); @@ -116,18 +115,16 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch * @throws Exception if any exception occurs during the test execution */ @Test + @ShardsFixed(num = 2) public void testSingleLexicalQuery() throws Exception { prepareIndexDocs(); - QueryResponse rsp = - query( - CommonParams.JSON, - "{\"queries\":" - + "{\"lexical1\":{\"lucene\":{\"query\":\"id:2^10\"}}}," - + "\"limit\":5," - + "\"fields\":[\"id\",\"score\",\"title\"]," - + "\"params\":{\"combiner\":true,\"combiner.query\":[\"lexical1\"]}}", - CommonParams.QT, - "/search"); + String jsonQuery = + "{\"queries\":" + + "{\"lexical1\":{\"lucene\":{\"query\":\"id:2^10\"}}}," + + "\"limit\":5," + + "\"fields\":[\"id\",\"score\",\"title\"]," + + "\"params\":{\"combiner\":true,\"combiner.query\":[\"lexical1\"]}}"; + QueryResponse rsp = query(CommonParams.JSON, jsonQuery, CommonParams.QT, "/search"); assertEquals(1, rsp.getResults().size()); assertFieldValues(rsp.getResults(), id, "2"); } @@ -150,6 +147,7 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch * @throws Exception if any error occurs during the test execution */ @Test + @ShardsFixed(num = 2) public void testMultipleLexicalQuery() throws Exception { prepareIndexDocs(); String jsonQuery = @@ -170,13 +168,14 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch * @throws Exception the exception */ @Test + @ShardsFixed(num = 2) public void testMultipleQueryWithSort() throws Exception { prepareIndexDocs(); String jsonQuery = "{\"queries\":" + "{\"lexical1\":{\"lucene\":{\"query\":\"id:(2^2 OR 3^1 OR 6^2 OR 5^1)\"}}," + "\"lexical2\":{\"lucene\":{\"query\":\"id:(4^1 OR 5^2 OR 7^3 OR 10^2)\"}}}," - + "\"limit\":5,\"sort\":\"mod3_idv desc, score desc\"" + + "\"limit\":5,\"sort\":\"mod3_idv desc, score desc\"," + "\"fields\":[\"id\",\"score\",\"title\"]," + "\"params\":{\"combiner\":true,\"combiner.query\":[\"lexical1\",\"lexical2\"]}}"; QueryResponse rsp = query(CommonParams.JSON, jsonQuery, CommonParams.QT, "/search"); @@ -190,42 +189,34 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch * @throws Exception if any unexpected error occurs during the test execution. */ @Test + @ShardsFixed(num = 2) public void testHybridQueryWithPagination() throws Exception { prepareIndexDocs(); - QueryResponse rsp = - query( - CommonParams.JSON, - "{\"queries\":" - + "{\"lexical1\":{\"lucene\":{\"query\":\"id:(2^2 OR 3^1 OR 6^2 OR 5^1)\"}}," - + "\"lexical2\":{\"lucene\":{\"query\":\"id:(4^1 OR 5^2 OR 7^3 OR 10^2)\"}}}," - + "\"fields\":[\"id\",\"score\",\"title\"]," - + "\"params\":{\"combiner\":true,\"combiner.query\":[\"lexical1\",\"lexical2\"]}}", - CommonParams.QT, - "/search"); + String jsonQueryAll = + "{\"queries\":" + + "{\"lexical1\":{\"lucene\":{\"query\":\"id:(2^2 OR 3^1 OR 6^2 OR 5^1)\"}}," + + "\"lexical2\":{\"lucene\":{\"query\":\"id:(4^1 OR 5^2 OR 7^3 OR 10^2)\"}}}," + + "\"fields\":[\"id\",\"score\",\"title\"]," + + "\"params\":{\"combiner\":true,\"combiner.query\":[\"lexical1\",\"lexical2\"]}}"; + QueryResponse rsp = query(CommonParams.JSON, jsonQueryAll, CommonParams.QT, "/search"); assertFieldValues(rsp.getResults(), id, "5", "7", "2", "6", "3", "10", "4"); - rsp = - query( - CommonParams.JSON, - "{\"queries\":" - + "{\"lexical1\":{\"lucene\":{\"query\":\"id:(2^2 OR 3^1 OR 6^2 OR 5^1)\"}}," - + "\"lexical2\":{\"lucene\":{\"query\":\"id:(4^1 OR 5^2 OR 7^3 OR 10^2)\"}}}," - + "\"limit\":4," - + "\"fields\":[\"id\",\"score\",\"title\"]," - + "\"params\":{\"combiner\":true,\"combiner.query\":[\"lexical1\",\"lexical2\"]}}", - CommonParams.QT, - "/search"); + String jsonQueryLimit4 = + "{\"queries\":" + + "{\"lexical1\":{\"lucene\":{\"query\":\"id:(2^2 OR 3^1 OR 6^2 OR 5^1)\"}}," + + "\"lexical2\":{\"lucene\":{\"query\":\"id:(4^1 OR 5^2 OR 7^3 OR 10^2)\"}}}," + + "\"limit\":4," + + "\"fields\":[\"id\",\"score\",\"title\"]," + + "\"params\":{\"combiner\":true,\"combiner.query\":[\"lexical1\",\"lexical2\"]}}"; + rsp = query(CommonParams.JSON, jsonQueryLimit4, CommonParams.QT, "/search"); assertFieldValues(rsp.getResults(), id, "5", "7", "2", "6"); - rsp = - query( - CommonParams.JSON, - "{\"queries\":" - + "{\"lexical1\":{\"lucene\":{\"query\":\"id:(2^2 OR 3^1 OR 6^2 OR 5^1)\"}}," - + "\"lexical2\":{\"lucene\":{\"query\":\"id:(4^1 OR 5^2 OR 7^3 OR 10^2)\"}}}," - + "\"limit\":4,\"offset\":3," - + "\"fields\":[\"id\",\"score\",\"title\"]," - + "\"params\":{\"combiner\":true,\"combiner.query\":[\"lexical1\",\"lexical2\"]}}", - CommonParams.QT, - "/search"); + String jsonQueryPage = + "{\"queries\":" + + "{\"lexical1\":{\"lucene\":{\"query\":\"id:(2^2 OR 3^1 OR 6^2 OR 5^1)\"}}," + + "\"lexical2\":{\"lucene\":{\"query\":\"id:(4^1 OR 5^2 OR 7^3 OR 10^2)\"}}}," + + "\"limit\":4,\"offset\":3," + + "\"fields\":[\"id\",\"score\",\"title\"]," + + "\"params\":{\"combiner\":true,\"combiner.query\":[\"lexical1\",\"lexical2\"]}}"; + rsp = query(CommonParams.JSON, jsonQueryPage, CommonParams.QT, "/search"); assertEquals(4, rsp.getResults().size()); assertFieldValues(rsp.getResults(), id, "6", "3", "10", "4"); } @@ -236,15 +227,16 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch * @throws Exception if any unexpected error occurs during the test execution. */ @Test + @ShardsFixed(num = 2) public void testQueryWithFaceting() throws Exception { prepareIndexDocs(); String jsonQuery = "{\"queries\":" + "{\"lexical\":{\"lucene\":{\"query\":\"id:(2^2 OR 3^1 OR 6^2 OR 5^1)\"}}}," - + "\"limit\":3,\"offset\":1" + + "\"limit\":3,\"offset\":1," + "\"fields\":[\"id\",\"score\",\"title\"]," - + "\"params\":{\"combiner\":true,\"facet\":true,\"facet.field\":\"mod3_idv\",\"facet.mincount\":1," - + "\"combiner.query\":[\"lexical\"]}}"; + + "\"params\":{\"combiner\":true,\"facet\":true,\"facet.field\":\"mod3_idv\"," + + "\"facet.mincount\":1,\"combiner.query\":[\"lexical\"]}}"; QueryResponse rsp = query(CommonParams.JSON, jsonQuery, CommonParams.QT, "/search"); assertEquals(3, rsp.getResults().size()); assertEquals(4, rsp.getResults().getNumFound()); @@ -257,6 +249,7 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch * @throws Exception if any unexpected error occurs during the test execution. */ @Test + @ShardsFixed(num = 2) public void testQueriesWithFacetAndHighlights() throws Exception { prepareIndexDocs(); String jsonQuery = @@ -266,8 +259,8 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch + "\"limit\":4," + "\"fields\":[\"id\",\"score\",\"title\"]," + "\"params\":{\"combiner\":true,\"facet\":true,\"facet.field\":\"mod3_idv\"," - + "\"combiner.query\":[\"lexical1\",\"lexical2\"], \"hl\": true," - + "\"hl.fl\": \"title\",\"hl.q\":\"test doc\"}}"; + + "\"combiner.query\":[\"lexical1\",\"lexical2\"],\"hl\":true,\"hl.fl\":\"title\"," + + "\"hl.q\":\"test doc\"}}"; QueryResponse rsp = query(CommonParams.JSON, jsonQuery, CommonParams.QT, "/search"); assertEquals(4, rsp.getResults().size()); assertFieldValues(rsp.getResults(), id, "5", "7", "2", "6"); @@ -286,6 +279,7 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch * @see org.apache.solr.handler.component.CombinedQuerySolrCloudTest#testForcedDistrib() */ @Test + @ShardsFixed(num = 2) public void testForcedDistrib() throws Exception { QueryResponse rsp = query("qt", "/forcedDistribTest", "q", "*:*", "rows", "0"); // ForcedDistribSearchHandler would trigger a failure if this didn't work @@ -318,6 +312,7 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch * collapse field. */ @Test + @ShardsFixed(num = 2) public void testCollapseWithCombinedQueryProducesDuplicates() throws Exception { del("*:*"); @@ -356,9 +351,6 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch // After collapse, each query returns 3 docs (one per mod3_idv value 0,1,2). // But the group heads for mod3_idv=1 differ: query1 picks id=1, query2 picks id=4. // simpleCombine() merges by doc ID, so both id=1 and id=4 survive → duplicate on mod3_idv=1. - // q1 -> 1,2,5,3,6 q2 -> 2,4,6,3,5 - // q1 -> 1,2,2,0,0 q2 -> 2,1,0,0,2 - // q1 -> 1 for sure, 2,3 => 4 for sure, 3 and 2 String jsonQuery = "{" + " \"queries\": {" @@ -399,7 +391,12 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch + "}"; handle.put("expanded", UNORDERED); - QueryResponse rsp = query(CommonParams.JSON, jsonQuery, CommonParams.QT, "/search"); + QueryResponse rsp; + try { + rsp = query(CommonParams.JSON, jsonQuery, CommonParams.QT, "/search"); + } finally { + handle.remove("expanded"); + } // Collect mod3_idv values from the result to check for duplicates List<Integer> collapseValues = new ArrayList<>(); @@ -415,8 +412,8 @@ public class DistributedCombinedQueryComponentTest extends BaseDistributedSearch "Expected no duplicate collapse field values in combined results, " + "but got collapseValues=" + collapseValues, - uniqueCollapseValues, - collapseValues.size()); + collapseValues.size(), + uniqueCollapseValues); assertEquals("Expected exactly 3 groups (mod3_idv values 0, 1, 2)", 3, collapseValues.size()); assertEquals("id", rsp.getFacetFields().get(0).getName()); assertEquals(
