You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ge...@apache.org on 2020/09/06 01:58:56 UTC

[lucene-solr] branch branch_8x updated: SOLR-14821: {!terms} dVTFTL supports single-valued strings

This is an automated email from the ASF dual-hosted git repository.

gerlowskija pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new de06e66  SOLR-14821: {!terms} dVTFTL supports single-valued strings
de06e66 is described below

commit de06e660d2a82e272519977f669e42664b782605
Author: Jason Gerlowski <ja...@lucidworks.com>
AuthorDate: Fri Sep 4 10:45:31 2020 -0400

    SOLR-14821: {!terms} dVTFTL supports single-valued strings
    
    Prior to this commit the docValuesTermsFilterTopLevel method of the
    {!terms} query parser would return zero results when run against a
    single-valued String.  This commit fixes this by wrapping the
    single-valued 'SortedDocValues' in a 'SortedSetDocValues' object.
---
 solr/CHANGES.txt                                       |  3 +++
 .../org/apache/solr/search/TermsQParserPlugin.java     |  4 ++--
 .../org/apache/solr/search/TestTermsQParserPlugin.java | 18 +++++++++---------
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d1f41d4..74f6222 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -98,6 +98,9 @@ Bug Fixes
 * SOLR-14714: Solr.cmd in windows loads the incorrect jetty module when using java>=9 (Endika Posadas via
   Erick 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.java
index 9a8a12a..3320655 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.java
index bd501e9..39130ae 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 value
       ModifiableSolrParams 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 values
       params = 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']",