From 499b06085f47dbdd20abc00e0d75610c09eb9f16 Mon Sep 17 00:00:00 2001 From: Narendra Pratap Singh <72899015+Narendra9793@users.noreply.github.com> Date: Sun, 24 Aug 2025 14:53:25 +0530 Subject: [PATCH] LUCENE-14611: Fix TestTermInSetQuery.testDuel OOM by reducing large randomized term sets --- .../lucene/search/TestTermInSetQuery.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lucene/core/src/test/org/apache/lucene/search/TestTermInSetQuery.java b/lucene/core/src/test/org/apache/lucene/search/TestTermInSetQuery.java index b65030216175..156ca2fc1e93 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestTermInSetQuery.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestTermInSetQuery.java @@ -112,16 +112,23 @@ public void testAllDocsInFieldTerm() throws IOException { public void testDuel() throws IOException { final int iters = atLeast(2); final String field = "f"; + final int maxTerms = 256; for (int iter = 0; iter < iters; ++iter) { final List allTerms = new ArrayList<>(); - final int numTerms = TestUtil.nextInt(random(), 1, 1 << TestUtil.nextInt(random(), 1, 10)); + // final int numTerms = TestUtil.nextInt(random(), 1, 1 << TestUtil.nextInt(random(), 1, 10)); + final int numTerms = Math.min( + TestUtil.nextInt(random(), 1, 1 << TestUtil.nextInt(random(), 1, 10)), + maxTerms + ); for (int i = 0; i < numTerms; ++i) { final String value = TestUtil.randomAnalysisString(random(), 10, true); allTerms.add(newBytesRef(value)); } Directory dir = newDirectory(); RandomIndexWriter iw = new RandomIndexWriter(random(), dir); - final int numDocs = atLeast(10_000); + // final int numDocs = atLeast(10_000); + final int maxDocs = 20000; + final int numDocs = Math.min(atLeast(10_000), maxDocs); for (int i = 0; i < numDocs; ++i) { Document doc = new Document(); final BytesRef term = allTerms.get(random().nextInt(allTerms.size())); @@ -148,7 +155,11 @@ public void testDuel() throws IOException { for (int i = 0; i < 100; ++i) { final float boost = random().nextFloat() * 10; final int numQueryTerms = - TestUtil.nextInt(random(), 1, 1 << TestUtil.nextInt(random(), 1, 8)); + // TestUtil.nextInt(random(), 1, 1 << TestUtil.nextInt(random(), 1, 8)); + Math.min( + TestUtil.nextInt(random(), 1, 1 << TestUtil.nextInt(random(), 1, 8)), + 256 + ); List queryTerms = new ArrayList<>(); for (int j = 0; j < numQueryTerms; ++j) { queryTerms.add(allTerms.get(random().nextInt(allTerms.size())));