Apache Lucene open-source search software
Fix LukeRequestHandler so it doesn't rely on SolrQueryParser and report incorrect stats when field names contain special characters
Chris M. Hostetterda8dd622e311
diff --git a/CHANGES.txt b/CHANGES.txtindex e14c07bf333..f7ca7f83e82 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -439,6 +439,11 @@ Bug Fixesnever manifested in normal Solr use and only potentially affectcustom code. (yonik)+53. SOLR-1171: Fix LukeRequestHandler so it doesn't rely on SolrQueryParser+ and report incorrect stats when field names contain characters+ SolrQueryParser considers special.+ (hossman)+Other Changes----------------------1. Upgraded to Lucene 2.4.0 (yonik)diff --git a/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java b/src/java/org/apache/solr/handler/admin/LukeRequestHandler.javaindex 4ad864ef152..6fdd2baf0a2 100644--- a/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java+++ b/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java@@ -40,6 +40,7 @@ import org.apache.lucene.index.Term;import org.apache.lucene.index.TermEnum;import org.apache.lucene.index.TermFreqVector;import org.apache.lucene.search.Query;+import org.apache.lucene.search.ConstantScoreRangeQuery;import org.apache.lucene.search.TopDocs;import org.apache.lucene.store.Directory;import org.apache.lucene.util.PriorityQueue;@@ -59,7 +60,6 @@ import org.apache.solr.schema.FieldType;import org.apache.solr.schema.IndexSchema;import org.apache.solr.schema.SchemaField;import org.apache.solr.search.SolrIndexSearcher;-import org.apache.solr.search.SolrQueryParser;/*** This handler exposes the internal lucene index. It is inspired by and@@ -273,7 +273,6 @@ public class LukeRequestHandler extends RequestHandlerBaseprivate static SimpleOrderedMap<Object> getIndexedFieldsInfo(final SolrIndexSearcher searcher, final Set<String> fields, final int numTerms )throws Exception {- SolrQueryParser qp = searcher.getSchema().getSolrQueryParser(null);IndexReader reader = searcher.getReader();IndexSchema schema = searcher.getSchema();@@ -303,7 +302,7 @@ public class LukeRequestHandler extends RequestHandlerBase// If numTerms==0, the call is just asking for a quick field listif( ttinfo != null && sfield != null && sfield.indexed() ) {- Query q = qp.parse( fieldName+":[* TO *]" );+ Query q = new ConstantScoreRangeQuery(fieldName,null,null,false,false);TopDocs top = searcher.search( q, 1 );if( top.totalHits > 0 ) {// Find a document with this field