Apache Solr open-source search software
SOLR-14821: {!terms} dVTFTL supports single-valued strings
Jason Gerlowskiecb8ca2fef7c
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex ffaf08bec84..363aad5a71a 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -217,6 +217,9 @@ Bug Fixes* SOLR-14714: Solr.cmd in windows loads the incorrect jetty module when using java>=9 (Endika Posadas viaErick Erickson)+* SOLR-14821: {!terms} docValuesTermsFilterTopLevel method now works with single-valued strings (Anatolii Siuniaev+ via Jason Gerlowski)+Other Changes---------------------diff --git a/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.javaindex 9a8a12ad564..3320655e58d 100644--- a/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java+++ b/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java@@ -205,8 +205,8 @@ public class TermsQParserPlugin extends QParserPlugin {if (! matchesAtLeastOneTerm) {return null;}-- SortedSetDocValues segmentDocValues = context.reader().getSortedSetDocValues(fieldName);++ SortedSetDocValues segmentDocValues = DocValues.getSortedSet(context.reader(), fieldName);if (segmentDocValues == null) {return null;}diff --git a/solr/core/src/test/org/apache/solr/search/TestTermsQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/TestTermsQParserPlugin.javaindex bd501e93dcd..39130ae92dd 100644--- a/solr/core/src/test/org/apache/solr/search/TestTermsQParserPlugin.java+++ b/solr/core/src/test/org/apache/solr/search/TestTermsQParserPlugin.java@@ -28,14 +28,14 @@ public class TestTermsQParserPlugin extends SolrTestCaseJ4 {public static void beforeClass() throws Exception {initCore("solrconfig.xml", "schema.xml");- assertU(adoc("id","1", "author_s", "Lev Grossman", "t_title", "The Magicians", "cat_s", "fantasy", "pubyear_i", "2009"));- assertU(adoc("id", "2", "author_s", "Robert Jordan", "t_title", "The Eye of the World", "cat_s", "fantasy", "cat_s", "childrens", "pubyear_i", "1990"));- assertU(adoc("id", "3", "author_s", "Robert Jordan", "t_title", "The Great Hunt", "cat_s", "fantasy", "cat_s", "childrens", "pubyear_i", "1990"));- assertU(adoc("id", "4", "author_s", "N.K. Jemisin", "t_title", "The Fifth Season", "cat_s", "fantasy", "pubyear_i", "2015"));+ assertU(adoc("id","1", "author_s1", "Lev Grossman", "t_title", "The Magicians", "cat_s", "fantasy", "pubyear_i", "2009"));+ assertU(adoc("id", "2", "author_s1", "Robert Jordan", "t_title", "The Eye of the World", "cat_s", "fantasy", "cat_s", "childrens", "pubyear_i", "1990"));+ assertU(adoc("id", "3", "author_s1", "Robert Jordan", "t_title", "The Great Hunt", "cat_s", "fantasy", "cat_s", "childrens", "pubyear_i", "1990"));+ assertU(adoc("id", "4", "author_s1", "N.K. Jemisin", "t_title", "The Fifth Season", "cat_s", "fantasy", "pubyear_i", "2015"));assertU(commit());- assertU(adoc("id", "5", "author_s", "Ursula K. Le Guin", "t_title", "The Dispossessed", "cat_s", "scifi", "pubyear_i", "1974"));- assertU(adoc("id", "6", "author_s", "Ursula K. Le Guin", "t_title", "The Left Hand of Darkness", "cat_s", "scifi", "pubyear_i", "1969"));- assertU(adoc("id", "7", "author_s", "Isaac Asimov", "t_title", "Foundation", "cat_s", "scifi", "pubyear_i", "1951"));+ assertU(adoc("id", "5", "author_s1", "Ursula K. Le Guin", "t_title", "The Dispossessed", "cat_s", "scifi", "pubyear_i", "1974"));+ assertU(adoc("id", "6", "author_s1", "Ursula K. Le Guin", "t_title", "The Left Hand of Darkness", "cat_s", "scifi", "pubyear_i", "1969"));+ assertU(adoc("id", "7", "author_s1", "Isaac Asimov", "t_title", "Foundation", "cat_s", "scifi", "pubyear_i", "1951"));assertU(commit());}@@ -114,7 +114,7 @@ public class TestTermsQParserPlugin extends SolrTestCaseJ4 {for (TermsParams method : methods) {// Single-valued field, single term valueModifiableSolrParams params = new ModifiableSolrParams();- params.add("q", method.buildQuery("author_s", "Robert Jordan"));+ params.add("q", method.buildQuery("author_s1", "Robert Jordan"));params.add("sort", "id asc");assertQ(req(params, "indent", "on"), "*[count(//doc)=2]","//result/doc[1]/str[@name='id'][.='2']",@@ -123,7 +123,7 @@ public class TestTermsQParserPlugin extends SolrTestCaseJ4 {// Single-valued field, multiple term valuesparams = new ModifiableSolrParams();- params.add("q", method.buildQuery("author_s", "Robert Jordan,Isaac Asimov"));+ params.add("q", method.buildQuery("author_s1", "Robert Jordan,Isaac Asimov"));params.add("sort", "id asc");assertQ(req(params, "indent", "on"), "*[count(//doc)=3]","//result/doc[1]/str[@name='id'][.='2']",