This is an automated email from the ASF dual-hosted git repository.
janhoy pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_10x by this push:
new ba8e08e7867 DistributedCombinedQueryComponentTest hangs in nightly
(#4497)
ba8e08e7867 is described below
commit ba8e08e786770f8896c2c9dc035f04a76a9e2d18
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 | 195 +++++++++++++--------
1 file changed, 119 insertions(+), 76 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 bb9105cad30..f4e4572ec7c 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,20 @@ 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,15 +151,20 @@ 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 =
- "{\"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,"
- + "\"fields\":[\"id\",\"score\",\"title\"],"
- +
"\"params\":{\"combiner\":true,\"combiner.query\":[\"lexical1\",\"lexical2\"]}}";
+ """
+ {
+ "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,
+ "fields": ["id", "score", "title"],
+ "params": {"combiner": true, "combiner.query": ["lexical1",
"lexical2"]}
+ }""";
QueryResponse rsp = query(CommonParams.JSON, jsonQuery, CommonParams.QT,
"/search");
assertEquals(5, rsp.getResults().size());
assertFieldValues(rsp.getResults(), id, "5", "7", "2", "6", "3");
@@ -170,15 +176,21 @@ 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\""
- + "\"fields\":[\"id\",\"score\",\"title\"],"
- +
"\"params\":{\"combiner\":true,\"combiner.query\":[\"lexical1\",\"lexical2\"]}}";
+ """
+ {
+ "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",
+ "fields": ["id", "score", "title"],
+ "params": {"combiner": true, "combiner.query": ["lexical1",
"lexical2"]}
+ }""";
QueryResponse rsp = query(CommonParams.JSON, jsonQuery, CommonParams.QT,
"/search");
assertEquals(5, rsp.getResults().size());
assertFieldValues(rsp.getResults(), id, "5", "2", "7", "10", "4");
@@ -190,42 +202,47 @@ 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 +253,26 @@ 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"
- + "\"fields\":[\"id\",\"score\",\"title\"],"
- +
"\"params\":{\"combiner\":true,\"facet\":true,\"facet.field\":\"mod3_idv\",\"facet.mincount\":1,"
- + "\"combiner.query\":[\"lexical\"]}}";
+ """
+ {
+ "queries": {
+ "lexical": {"lucene": {"query": "id:(2^2 OR 3^1 OR 6^2 OR 5^1)"}}
+ },
+ "limit": 3,
+ "offset": 1,
+ "fields": ["id", "score", "title"],
+ "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,17 +285,28 @@ 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 =
- "{\"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,\"facet\":true,\"facet.field\":\"mod3_idv\","
- + "\"combiner.query\":[\"lexical1\",\"lexical2\"], \"hl\": true,"
- + "\"hl.fl\": \"title\",\"hl.q\":\"test doc\"}}";
+ """
+ {
+ "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,
+ "facet": true,
+ "facet.field": "mod3_idv",
+ "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 +325,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 +358,7 @@ public class DistributedCombinedQueryComponentTest extends
BaseDistributedSearch
* collapse field.
*/
@Test
+ @ShardsFixed(num = 2)
public void testCollapseWithCombinedQueryProducesDuplicates() throws
Exception {
del("*:*");
@@ -356,9 +397,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 =
"""
{
@@ -400,7 +438,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<>();
@@ -416,8 +459,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().getFirst().getName());
assertEquals(