diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index dc24cf5fd63..d2aeadb14aa 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -136,6 +136,11 @@ Bug Fixes of matching something due to filter exclusions (which can widen the domain again). (Michael Sun, yonik) +* SOLR-9740: A bug in macro expansion of multi-valued parameters caused non-expanded values + after the first expanded value in the same multi-valued parameter to be dropped. + (Erik Hatcher, yonik) + + Other Changes ---------------------- diff --git a/solr/core/src/java/org/apache/solr/request/macro/MacroExpander.java b/solr/core/src/java/org/apache/solr/request/macro/MacroExpander.java index 305a9759f7c..9d432fa6ec6 100644 --- a/solr/core/src/java/org/apache/solr/request/macro/MacroExpander.java +++ b/solr/core/src/java/org/apache/solr/request/macro/MacroExpander.java @@ -71,6 +71,8 @@ public class MacroExpander { newValues.add(vv); } } + } + if (newValues != null) { newValues.add(newV); } } diff --git a/solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.java b/solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.java index 5b16a11e849..e908037cdd8 100644 --- a/solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.java +++ b/solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.java @@ -113,4 +113,17 @@ public class TestMacroExpander extends LuceneTestCase { } } + @Test + public void testMap() { // see SOLR-9740, the second fq param was being dropped. + final Map request = new HashMap<>(); + request.put("fq", new String[] {"zero", "${one_ref}", "two", "${three_ref}"}); + request.put("one_ref",new String[] {"one"}); + request.put("three_ref",new String[] {"three"}); + Map expanded = MacroExpander.expand(request); + assertEquals("zero", ((String[])expanded.get("fq"))[0]); + assertEquals("one", ((String[])expanded.get("fq"))[1]); + assertEquals("two", ((String[]) expanded.get("fq"))[2]); + assertEquals("three", ((String[]) expanded.get("fq"))[3]); + } + }