[ https://issues.apache.org/jira/browse/SOLR-15389?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17337611#comment-17337611 ]
Mike Drob commented on SOLR-15389: ---------------------------------- I've started working on this, and wondering if there is a better approach than this... {noformat} diff --git a/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java b/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java index a46c78fc6d5..1757d4f2da8 100644 --- a/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java +++ b/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java @@ -25,10 +25,12 @@ import java.util.Locale; import java.util.Map; import java.util.Random; +import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.BoostQuery; import org.apache.lucene.search.ConstantScoreQuery; +import org.apache.lucene.search.DisjunctionMaxQuery; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.NormsFieldExistsQuery; @@ -1211,11 +1213,25 @@ public class TestSolrQueryParser extends SolrTestCaseJ4 { public void testSynonymQueryStyle() throws Exception { - Query q = QParser.getParser("tabby", req(params("df", "t_pick_best_foo"))).getQuery(); - assertEquals("(t_pick_best_foo:tabbi | t_pick_best_foo:cat | t_pick_best_foo:felin | t_pick_best_foo:anim)", q.toString()); - - q = QParser.getParser("tabby", req(params("df", "t_as_distinct_foo"))).getQuery(); - assertEquals("t_as_distinct_foo:tabbi t_as_distinct_foo:cat t_as_distinct_foo:felin t_as_distinct_foo:anim", q.toString()); + String field = "t_pick_best_foo"; + Query q = QParser.getParser("tabby", req(params("df", field))).getQuery(); + Query expected = new DisjunctionMaxQuery(List.of( + new TermQuery(new Term(field,"cat")), + new TermQuery(new Term(field,"tabbi")), + new TermQuery(new Term(field,"anim")), + new TermQuery(new Term(field,"felin"))), + 0.0f); + assertEquals(expected, q); + + field = "t_as_distinct_foo"; + q = QParser.getParser("tabby", req(params("df", field))).getQuery(); + expected = new BooleanQuery.Builder() + .add(new BooleanClause(new TermQuery(new Term(field,"cat")), BooleanClause.Occur.SHOULD)) + .add(new BooleanClause(new TermQuery(new Term(field,"tabbi")), BooleanClause.Occur.SHOULD)) + .add(new BooleanClause(new TermQuery(new Term(field,"anim")), BooleanClause.Occur.SHOULD)) + .add(new BooleanClause(new TermQuery(new Term(field,"felin")), BooleanClause.Occur.SHOULD)) + .build(); + assertEquals(expected, q); /*confirm autoGeneratePhraseQueries always builds OR queries*/ q = QParser.getParser("jeans", req(params("df", "t_as_distinct_foo", "sow", "false"))).getQuery(); {noformat} > Certain tests rely on DisjunctionMaxQuery clause order > ------------------------------------------------------- > > Key: SOLR-15389 > URL: https://issues.apache.org/jira/browse/SOLR-15389 > Project: Solr > Issue Type: Test > Security Level: Public(Default Security Level. Issues are Public) > Reporter: Mike Drob > Priority: Major > > Broken by LUCENE-9940 > Test failures e.g. > org.apache.solr.search.TestSolrQueryParser.testSynonymQueryStyle > {noformat} > org.junit.ComparisonFailure: > <(t_pick_best_foo:[tabbi | t_pick_best_foo:cat | t_pick_best_foo:felin] | > t_pick_best_foo:a...> > <(t_pick_best_foo:[felin | t_pick_best_foo:cat | t_pick_best_foo:tabbi] | > t_pick_best_foo:a...> > {noformat} -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org