You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by kr...@apache.org on 2022/10/26 20:40:12 UTC
[solr] 02/02: SOLR-16293: Luke request fails for document with a binary field (#1134)
This is an automated email from the ASF dual-hosted git repository.
krisden pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 43a42a69fe393bae4736d12314c3fb12c3eb69f4
Author: Kevin Risden <ri...@users.noreply.github.com>
AuthorDate: Wed Oct 26 16:35:09 2022 -0400
SOLR-16293: Luke request fails for document with a binary field (#1134)
---
solr/CHANGES.txt | 2 ++
.../java/org/apache/solr/handler/admin/LukeRequestHandler.java | 8 ++++----
solr/core/src/test-files/solr/collection1/conf/schema12.xml | 3 +++
.../org/apache/solr/handler/admin/LukeRequestHandlerTest.java | 4 +++-
4 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 70f44ef4aef..363b84c757c 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -51,6 +51,8 @@ Bug Fixes
* SOLR-16363: DirectUpdateHandler2 should not throw UnknownFormatConversionException (Kevin Risden)
+* SOLR-16293: Luke request fails for document with a binary field (Kevin Risden)
+
Build
---------------------
* Upgrade forbiddenapis to 3.4 (Uwe Schindler)
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
index b430094a1ed..da247e6e05a 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
@@ -32,6 +32,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
@@ -122,7 +123,7 @@ public class LukeRequestHandler extends RequestHandlerBase {
if ("all".equalsIgnoreCase(v)) return ALL;
throw new SolrException(ErrorCode.BAD_REQUEST, "Unknown Show Style: " + v);
}
- };
+ }
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
@@ -341,10 +342,9 @@ public class LukeRequestHandler extends RequestHandlerBase {
.array(),
StandardCharsets.ISO_8859_1));
}
- if (!ftype.isPointField()) {
+ if (ftype != null && !ftype.isPointField()) {
Term t =
- new Term(
- field.name(), ftype != null ? ftype.storedToIndexed(field) : field.stringValue());
+ new Term(field.name(), Objects.requireNonNullElse(ftype.storedToIndexed(field), ""));
f.add(
"docFreq",
t.text() == null ? 0 : reader.docFreq(t)); // this can be 0 for non-indexed fields
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema12.xml b/solr/core/src/test-files/solr/collection1/conf/schema12.xml
index 336bfdc6661..16be4aa17cd 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema12.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema12.xml
@@ -104,6 +104,8 @@
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
<fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
+ <fieldType name="binary" class="solr.BinaryField"/>
+
<!-- format for date is 1995-12-31T23:59:59.999Z and only the fractional
seconds part (.999) is optional.
-->
@@ -684,6 +686,7 @@
<dynamicField name="t_as_same_term_boosted_*" type="text_as_same_term_boosted" indexed="true" stored="true"/>
<dynamicField name="t_as_distinct_*" type="text_as_distinct" indexed="true" stored="true"/>
+ <dynamicField name="*_bin" type="binary"/>
<dynamicField name="t_*" type="text" indexed="true" stored="true"/>
<dynamicField name="tv_*" type="text" indexed="true" stored="true"
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java
index 8b2461b5c98..c3479340564 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java
@@ -76,7 +76,9 @@ public class LukeRequestHandlerTest extends SolrTestCaseJ4 {
"solr_dt",
"2000-01-01T01:01:01Z",
"solr_tdt",
- "2000-01-01T01:01:01Z"));
+ "2000-01-01T01:01:01Z",
+ "solr_bin",
+ "PS9cPQ=="));
assertU(commit());
}