lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r883178 - in /lucene/solr/trunk: CHANGES.txt src/java/org/apache/solr/handler/admin/LukeRequestHandler.java src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java
Date Sun, 22 Nov 2009 22:57:09 GMT
Author: yonik
Date: Sun Nov 22 22:57:08 2009
New Revision: 883178

URL: http://svn.apache.org/viewvc?rev=883178&view=rev
Log:
SOLR-1563: fix luke for binary fields

Modified:
    lucene/solr/trunk/CHANGES.txt
    lucene/solr/trunk/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
    lucene/solr/trunk/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java

Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=883178&r1=883177&r2=883178&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Sun Nov 22 22:57:08 2009
@@ -61,6 +61,9 @@
 
 * SOLR-1582: Fix BinaryField copy in DocumentBuilder (gsingers)
 
+* SOLR-1563: Binary fields, including trie-based numeric fields, caused null
+  pointer exceptions in the luke request handler. (yonik)
+
 
 Other Changes
 ----------------------

Modified: lucene/solr/trunk/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java?rev=883178&r1=883177&r2=883178&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java Sun Nov
22 22:57:08 2009
@@ -53,6 +53,7 @@
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.Base64;
 import org.apache.solr.handler.RequestHandlerBase;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.SolrQueryResponse;
@@ -240,12 +241,20 @@
       f.add( "type", (ftype==null)?null:ftype.getTypeName() );
       f.add( "schema", getFieldFlags( sfield ) );
       f.add( "flags", getFieldFlags( fieldable ) );
-      
-      Term t = new Term( fieldable.name(), fieldable.stringValue() );
+
+      Term t = new Term(fieldable.name(), ftype!=null ? ftype.storedToIndexed(fieldable)
: fieldable.stringValue());
+
       f.add( "value", (ftype==null)?null:ftype.toExternal( fieldable ) );
+
+      // TODO: this really should be "stored"
       f.add( "internal", fieldable.stringValue() );  // may be a binary number
+
+      byte[] arr = fieldable.getBinaryValue();
+      if (arr != null) {
+        f.add( "binary", Base64.byteArrayToBase64(arr, 0, arr.length));
+      }
       f.add( "boost", fieldable.getBoost() );
-      f.add( "docFreq", reader.docFreq( t ) ); // this can be 0 for non-indexed fields
+      f.add( "docFreq", t.text()==null ? 0 : reader.docFreq( t ) ); // this can be 0 for
non-indexed fields
             
       // If we have a term vector, return that
       if( fieldable.isTermVectorStored() ) {

Modified: lucene/solr/trunk/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java?rev=883178&r1=883177&r2=883178&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java Sun
Nov 22 22:57:08 2009
@@ -17,17 +17,25 @@
 
 package org.apache.solr.handler.admin;
 
-import junit.framework.TestCase;
-
-import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.util.AbstractSolrTestCase;
 
 /**
  * :TODO: currently only tests some of the utilities in the LukeRequestHandler
  */
-public class LukeRequestHandlerTest extends TestCase {
-  
+public class LukeRequestHandlerTest extends AbstractSolrTestCase {
+
+  @Override
+  public String getSchemaFile() {
+    return "schema12.xml";
+  }
+
+  @Override
+  public String getSolrConfigFile() {
+    return "solrconfig.xml";
+  }
+
   /** tests some simple edge cases */
-  public void testHistogramPowerOfTwoBucket() {
+  public void doTestHistogramPowerOfTwoBucket() {
     assertHistoBucket(1,  1);
     assertHistoBucket(2,  2);
     assertHistoBucket(4,  3);
@@ -45,8 +53,47 @@
     assertHistoBucket(MAX_VALID*2, MAX_VALID+1 );
     
   }
+
   private void assertHistoBucket(int expected, int in) {
     assertEquals("histobucket: " + in, expected,
                  LukeRequestHandler.TermHistogram.getPowerOfTwoBucket( in ));
   }
+
+  public void testLuke() {
+    doTestHistogramPowerOfTwoBucket();
+
+    assertU(adoc("id","SOLR1000", "name","Apache Solr",
+      "solr_si", "10",
+      "solr_sl", "10",
+      "solr_sf", "10",
+      "solr_sd", "10",
+      "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_pi", "10",
+      "solr_pl", "10",
+      "solr_pf", "10",
+      "solr_pd", "10",
+      "solr_dt", "2000-01-01T01:01:01Z",
+      "solr_tdt", "2000-01-01T01:01:01Z",
+      "solr_pdt", "2000-01-01T01:01:01Z"
+    ));
+    assertU(commit());
+
+    // test that Luke can handle all of the field types
+    assertQ(req("qt","/admin/luke", "id","SOLR1000"));
+  }
+
+
 }



Mime
View raw message