You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kr...@apache.org on 2022/10/26 20:48:26 UTC

[lucene-solr] branch branch_8_11 updated: 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_8_11
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8_11 by this push:
     new 6ebd2815add SOLR-16293: Luke request fails for document with a binary field (#1134)
6ebd2815add is described below

commit 6ebd2815add5b6ab728b53b9d5f2fda31844046b
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 +
 .../solr/handler/admin/LukeRequestHandler.java     | 15 ++++--
 .../test-files/solr/collection1/conf/schema12.xml  |  3 ++
 .../solr/handler/admin/LukeRequestHandlerTest.java | 58 +++++++++++++++-------
 4 files changed, 55 insertions(+), 23 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 70b2e07a97f..3f42c9189cb 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -14,6 +14,8 @@ Bug Fixes
 
 * SOLR-14679: Fix continuously growing TLOGs on TLOG replicas (Viktor Molnár via Houston Putman)
 
+* SOLR-16293: Luke request fails for document with a binary field (Kevin Risden)
+
 Other Changes
 ---------------------
 * SOLR-16141: Upgrade Apache Tika to 1.28.4 (Kevin Risden)
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 5bb122f49ce..46320e9dcce 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
@@ -121,7 +121,7 @@ public class LukeRequestHandler extends RequestHandlerBase
       if("all".equalsIgnoreCase(v))    return ALL;
       throw new SolrException(ErrorCode.BAD_REQUEST, "Unknown Show Style: "+v);
     }
-  };
+  }
 
 
   @Override
@@ -300,10 +300,15 @@ public class LukeRequestHandler extends RequestHandlerBase
       if (bytes != null) {
         f.add( "binary", Base64.byteArrayToBase64(bytes.bytes, bytes.offset, bytes.length));
       }
-      if (!ftype.isPointField()) {
-        Term t = new Term(field.name(), ftype!=null ? ftype.storedToIndexed(field) : field.stringValue());
-        f.add( "docFreq", t.text()==null ? 0 : reader.docFreq( t ) ); // this can be 0 for non-indexed fields
-      }// TODO: Calculate docFreq for point fields
+
+      if (ftype != null && !ftype.isPointField()) {
+        String s = ftype.storedToIndexed(field);
+        if (s == null) s = "";
+        Term t = new Term(field.name(), s);
+        f.add(
+            "docFreq",
+            t.text() == null ? 0 : reader.docFreq(t)); // this can be 0 for non-indexed fields
+      } // TODO: Calculate docFreq for point fields
 
       // If we have a term vector, return that
       if( field.fieldType().storeTermVectors() ) {
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 d4cb89e85f8..8a88eaa1be5 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema12.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema12.xml
@@ -101,6 +101,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.
     -->
@@ -696,6 +698,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 8065f55488a..b7d141dc13e 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
@@ -45,24 +45,46 @@ public class LukeRequestHandlerTest extends SolrTestCaseJ4 {
 
   @Before
   public void before() {
-    assertU(adoc("id","SOLR1000", "name","Apache Solr",
-        "solr_s", "10",
-        "solr_sI", "10",
-        "solr_sS", "10",
-        "solr_t", "10",
-        "solr_tt", "10",
-        "solr_b", "true",
-        "solr_i", "10",
-        "solr_l", "10",
-        "solr_f", "10",
-        "solr_d", "10",
-        "solr_ti", "10",
-        "solr_tl", "10",
-        "solr_tf", "10",
-        "solr_td", "10",
-        "solr_dt", "2000-01-01T01:01:01Z",
-        "solr_tdt", "2000-01-01T01:01:01Z"
-    ));
+    assertU(
+        adoc(
+            "id",
+            "SOLR1000",
+            "name",
+            "Apache Solr",
+            "solr_s",
+            "10",
+            "solr_sI",
+            "10",
+            "solr_sS",
+            "10",
+            "solr_t",
+            "10",
+            "solr_tt",
+            "10",
+            "solr_b",
+            "true",
+            "solr_i",
+            "10",
+            "solr_l",
+            "10",
+            "solr_f",
+            "10",
+            "solr_d",
+            "10",
+            "solr_ti",
+            "10",
+            "solr_tl",
+            "10",
+            "solr_tf",
+            "10",
+            "solr_td",
+            "10",
+            "solr_dt",
+            "2000-01-01T01:01:01Z",
+            "solr_tdt",
+            "2000-01-01T01:01:01Z",
+            "solr_bin",
+            "PS9cPQ=="));
     assertU(commit());
 
   }