You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by mk...@apache.org on 2023/01/08 17:46:15 UTC
[solr] branch branch_9x updated: SOLR-16611: fix collapse hint=top_fc bug (#1274) (#1280)
This is an automated email from the ASF dual-hosted git repository.
mkhl pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 967fcd9bd96 SOLR-16611: fix collapse hint=top_fc bug (#1274) (#1280)
967fcd9bd96 is described below
commit 967fcd9bd960866d5e0beb1972dd48d5ee50b3f8
Author: Mikhail Khludnev <mk...@users.noreply.github.com>
AuthorDate: Sun Jan 8 20:46:09 2023 +0300
SOLR-16611: fix collapse hint=top_fc bug (#1274) (#1280)
* fixed collapse top_fc getSorted
Co-authored-by: Mikhail Khludnev <mk...@apache.org>
Co-authored-by: taku <84...@users.noreply.github.com>
---
solr/CHANGES.txt | 1 +
.../src/java/org/apache/solr/search/CollapsingQParserPlugin.java | 7 ++++++-
.../test/org/apache/solr/search/TestCollapseQParserPlugin.java | 8 ++++++--
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 5115ff0bb00..6b64b3dccb4 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -132,6 +132,7 @@ Bug Fixes
* SOLR-16605: CPU percent calculation incorrect in admin UI cloud->nodes tab (Shawn Heisey)
+* SOLR-16611: NullPointerException occus when there are no segments in `{!collapse hint=top_fc}` (Minami Takuya via Mikhail Khludnev)
Build
---------------------
diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
index a44673efbb2..8026fa16328 100644
--- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
@@ -2092,7 +2092,12 @@ public class CollapsingQParserPlugin extends QParserPlugin {
new EmptyDocValuesProducer() {
@Override
public SortedDocValues getSorted(FieldInfo ignored) throws IOException {
- return uninvertingReader.getSortedDocValues(collapseField);
+ SortedDocValues values = uninvertingReader.getSortedDocValues(collapseField);
+ if (values != null) {
+ return values;
+ } else {
+ return DocValues.emptySorted();
+ }
}
};
} else {
diff --git a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
index d6e20ed93d6..c28db60dfd9 100644
--- a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
@@ -440,6 +440,10 @@ public class TestCollapseQParserPlugin extends SolrTestCaseJ4 {
}
private void testCollapseQueries(String group, String hint, boolean numeric) {
+ ModifiableSolrParams params = new ModifiableSolrParams();
+ params.add("q", "*:*");
+ params.add("fq", "{!collapse field=" + group + "" + hint + "}");
+ assertQ(req(params, "indent", "on"), "*[count(//doc)=0]");
String[] doc = {
"id", "1", "term_s", "YYYY", group, "1", "test_i", "5", "test_l", "10", "test_f", "2000"
@@ -479,7 +483,7 @@ public class TestCollapseQParserPlugin extends SolrTestCaseJ4 {
assertU(commit());
// Test collapse by score and following sort by score
- ModifiableSolrParams params = new ModifiableSolrParams();
+ params = new ModifiableSolrParams();
params.add("q", "*:*");
params.add("fq", "{!collapse field=" + group + "" + hint + "}");
params.add("defType", "edismax");
@@ -1095,7 +1099,7 @@ public class TestCollapseQParserPlugin extends SolrTestCaseJ4 {
" sort='bogus_sort_s desc' ",
}) {
- ModifiableSolrParams params = null;
+ ModifiableSolrParams params;
// w/default nullPolicy, no groups found
params = new ModifiableSolrParams();