mirror of https://github.com/apache/lucene.git
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.
This commit is contained in:
parent
f71ba62d4a
commit
ecb8ca2fef
|
@ -217,6 +217,9 @@ Bug Fixes
|
||||||
* SOLR-14714: Solr.cmd in windows loads the incorrect jetty module when using java>=9 (Endika Posadas via
|
* SOLR-14714: Solr.cmd in windows loads the incorrect jetty module when using java>=9 (Endika Posadas via
|
||||||
Erick Erickson)
|
Erick Erickson)
|
||||||
|
|
||||||
|
* SOLR-14821: {!terms} docValuesTermsFilterTopLevel method now works with single-valued strings (Anatolii Siuniaev
|
||||||
|
via Jason Gerlowski)
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ public class TermsQParserPlugin extends QParserPlugin {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
SortedSetDocValues segmentDocValues = context.reader().getSortedSetDocValues(fieldName);
|
SortedSetDocValues segmentDocValues = DocValues.getSortedSet(context.reader(), fieldName);
|
||||||
if (segmentDocValues == null) {
|
if (segmentDocValues == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,14 +28,14 @@ public class TestTermsQParserPlugin extends SolrTestCaseJ4 {
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
initCore("solrconfig.xml", "schema.xml");
|
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","1", "author_s1", "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", "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_s", "Robert Jordan", "t_title", "The Great Hunt", "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_s", "N.K. Jemisin", "t_title", "The Fifth Season", "cat_s", "fantasy", "pubyear_i", "2015"));
|
assertU(adoc("id", "4", "author_s1", "N.K. Jemisin", "t_title", "The Fifth Season", "cat_s", "fantasy", "pubyear_i", "2015"));
|
||||||
assertU(commit());
|
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", "5", "author_s1", "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", "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_s", "Isaac Asimov", "t_title", "Foundation", "cat_s", "scifi", "pubyear_i", "1951"));
|
assertU(adoc("id", "7", "author_s1", "Isaac Asimov", "t_title", "Foundation", "cat_s", "scifi", "pubyear_i", "1951"));
|
||||||
assertU(commit());
|
assertU(commit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ public class TestTermsQParserPlugin extends SolrTestCaseJ4 {
|
||||||
for (TermsParams method : methods) {
|
for (TermsParams method : methods) {
|
||||||
// Single-valued field, single term value
|
// Single-valued field, single term value
|
||||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
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");
|
params.add("sort", "id asc");
|
||||||
assertQ(req(params, "indent", "on"), "*[count(//doc)=2]",
|
assertQ(req(params, "indent", "on"), "*[count(//doc)=2]",
|
||||||
"//result/doc[1]/str[@name='id'][.='2']",
|
"//result/doc[1]/str[@name='id'][.='2']",
|
||||||
|
@ -123,7 +123,7 @@ public class TestTermsQParserPlugin extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
// Single-valued field, multiple term values
|
// Single-valued field, multiple term values
|
||||||
params = new ModifiableSolrParams();
|
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");
|
params.add("sort", "id asc");
|
||||||
assertQ(req(params, "indent", "on"), "*[count(//doc)=3]",
|
assertQ(req(params, "indent", "on"), "*[count(//doc)=3]",
|
||||||
"//result/doc[1]/str[@name='id'][.='2']",
|
"//result/doc[1]/str[@name='id'][.='2']",
|
||||||
|
|
Loading…
Reference in New Issue