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 3d1f2c03054ed4621c5e943215ae84dc0277d2eb Author: Nick <[email protected]> AuthorDate: Sun Nov 15 13:50:30 2026 -0700 SOLR-18624: Test fix: TestMultiWordSynonyms.testPf flaky ordering assertions (#5294) (cherry picked from commit 63b6dcc287f452c48b95ac4c2de45299fb1af7e3) (cherry picked from commit 9435162ecab233e344130b8c5788281362ba864e) --- .../apache/solr/search/TestMultiWordSynonyms.java | 68 ++++++++++++++++++---- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/search/TestMultiWordSynonyms.java b/solr/core/src/test/org/apache/solr/search/TestMultiWordSynonyms.java index 2468f0ad2a2..7f2e210d8ea 100644 --- a/solr/core/src/test/org/apache/solr/search/TestMultiWordSynonyms.java +++ b/solr/core/src/test/org/apache/solr/search/TestMultiWordSynonyms.java @@ -100,31 +100,41 @@ public class TestMultiWordSynonyms extends SolrTestCaseJ4 { assertU(commit()); assertQ( - "default order assumption wrong", + "function boosts must determine baseline scores", req( "q", "foo bar", "qf", "text", "bf", "boost_d", "fl", "score,*", + "sort", "score desc,boost_d desc", "defType", "edismax"), "//doc[1]/str[@name='id'][.='13']", "//doc[2]/str[@name='id'][.='12']", "//doc[3]/str[@name='id'][.='11']", - "//doc[4]/str[@name='id'][.='10']"); + "//doc[4]/str[@name='id'][.='10']", + "//doc[1]/float[@name='score'][. > ../../doc[2]/float[@name='score']]", + "//doc[2]/float[@name='score'][. > ../../doc[3]/float[@name='score']]", + "//doc[3]/float[@name='score'][. > ../../doc[4]/float[@name='score']]"); assertQ( - "default order assumption wrong", + "function boosts must determine baseline scores", req( "q", "foo tropical cyclone", "qf", "text", "bf", "boost_d", "fl", "score,*", + "sort", "score desc,boost_d desc", "defType", "edismax"), "//doc[1]/str[@name='id'][.='13']", "//doc[2]/str[@name='id'][.='12']", "//doc[3]/str[@name='id'][.='11']", - "//doc[4]/str[@name='id'][.='10']"); + "//doc[4]/str[@name='id'][.='10']", + "//doc[1]/float[@name='score'][. > ../../doc[2]/float[@name='score']]", + "//doc[2]/float[@name='score'][. > ../../doc[3]/float[@name='score']]", + "//doc[3]/float[@name='score'][. > ../../doc[4]/float[@name='score']]"); + // A score tie must not let the low-boost document win by ID order. Compare its + // score directly with the highest-bf document, and break score ties by bf. assertQ( "pf not working", req( @@ -133,8 +143,10 @@ public class TestMultiWordSynonyms extends SolrTestCaseJ4 { "pf", "text^10", "fl", "score,*", "bf", "boost_d", + "sort", "score desc,boost_d desc", "defType", "edismax"), - "//doc[1]/str[@name='id'][.='10']"); + "//doc[1]/str[@name='id'][.='10']", + "//doc[str[@name='id'][.='10']]/float[@name='score'][number(.) > number(//doc[str[@name='id'][.='13']]/float[@name='score'])]"); assertQ( "pf not working", @@ -144,8 +156,10 @@ public class TestMultiWordSynonyms extends SolrTestCaseJ4 { "pf", "text^10", "fl", "score,*", "bf", "boost_d", + "sort", "score desc,boost_d desc", "defType", "edismax"), - "//doc[1]/str[@name='id'][.='10']"); + "//doc[1]/str[@name='id'][.='10']", + "//doc[str[@name='id'][.='10']]/float[@name='score'][number(.) > number(//doc[str[@name='id'][.='13']]/float[@name='score'])]"); assertQ( "pf2 not working", @@ -155,8 +169,10 @@ public class TestMultiWordSynonyms extends SolrTestCaseJ4 { "pf2", "text^10", "fl", "score,*", "bf", "boost_d", + "sort", "score desc,boost_d desc", "defType", "edismax"), - "//doc[1]/str[@name='id'][.='10']"); + "//doc[1]/str[@name='id'][.='10']", + "//doc[str[@name='id'][.='10']]/float[@name='score'][number(.) > number(//doc[str[@name='id'][.='13']]/float[@name='score'])]"); assertQ( "pf3 not working", @@ -166,8 +182,10 @@ public class TestMultiWordSynonyms extends SolrTestCaseJ4 { "pf3", "text^10", "fl", "score,*", "bf", "boost_d", + "sort", "score desc,boost_d desc", "defType", "edismax"), - "//doc[1]/str[@name='id'][.='12']"); + "//doc[1]/str[@name='id'][.='12']", + "//doc[str[@name='id'][.='12']]/float[@name='score'][number(.) > number(//doc[str[@name='id'][.='13']]/float[@name='score'])]"); assertQ( "pf3 not working", @@ -177,8 +195,22 @@ public class TestMultiWordSynonyms extends SolrTestCaseJ4 { "pf3", "text^10", "fl", "score,*", "bf", "boost_d", + "sort", "score desc,boost_d desc", "defType", "edismax"), - "//doc[1]/str[@name='id'][.='12']"); + "//doc[1]/str[@name='id'][.='12']", + "//doc[str[@name='id'][.='12']]/float[@name='score'][number(.) > number(//doc[str[@name='id'][.='13']]/float[@name='score'])]"); + + assertQ( + "pf2 must not boost a reversed phrase without slop", + req( + "q", "bar foo", + "qf", "text", + "pf2", "text^10", + "ps", "0", + "fl", "score,*", + "defType", "edismax"), + "//result[@name='response'][@numFound='4']", + "//doc[str[@name='id'][.='10']]/float[@name='score'][. = //doc[str[@name='id'][.='13']]/float[@name='score']]"); assertQ( "ps not working for pf2", @@ -188,9 +220,16 @@ public class TestMultiWordSynonyms extends SolrTestCaseJ4 { "pf2", "text^10", "ps", "2", "fl", "score,*", + "debugQuery", "true", "defType", "edismax"), - "//doc[1]/str[@name='id'][.='10']"); + "//result[@name='response'][@numFound='4']", + "//doc[str[@name='id'][.='10']]/float[@name='score'][. > //doc[str[@name='id'][.='13']]/float[@name='score']]", + "//doc[1]/str[@name='id'][.='10']", + "//str[@name='parsedquery'][contains(.,'text:\"bar foo\"~2')]", + "//str[@name='parsedquery'][contains(.,'text:\"tropical cyclone foo\"~2')]"); + // pf2 shingles the original words before synonym expansion. These bigrams + // give every document the same boost through "bar", so no first hit is required. assertQ( "ps not working for pf2", req( @@ -199,8 +238,15 @@ public class TestMultiWordSynonyms extends SolrTestCaseJ4 { "pf2", "text^10", "ps", "2", "fl", "score,*", + "debugQuery", "true", "defType", "edismax"), - "//doc[1]/str[@name='id'][.='10']"); + "//result[@name='response'][@numFound='4']", + "//doc/str[@name='id'][.='10']", + "//doc/str[@name='id'][.='11']", + "//doc/str[@name='id'][.='12']", + "//doc/str[@name='id'][.='13']", + "//str[@name='parsedquery'][contains(.,'(text:bar text:\"tropical cyclone\"~2)^10.0')]", + "//str[@name='parsedquery'][contains(.,'(text:\"cyclone foo\"~2)^10.0')]"); } @Test
