On May 21, 2007, at 11:00 PM, Ryan McKinley wrote:
If Ryan is date-less again tonight, I'm sure he'll have it all
fixed up by the time I wake up :) Otherwise, I'll dig in and roll
up my sleeves sometime this week and make some adjustments to
allow turning off the top terms feature.
Just back from a week of nothing that goes beep... it was great!
Nice!
Perhaps numTerms=0 would skip all term collecting... also, it may
be worth caching the top terms, but i don't really want to go there
just yet.
I think all the features of the Luke request handler should be made
optional, except for just feeding back the fields and types in the
index which seems a reasonable always-on feature.
Did you get a chance to look at the code? or should i add the
numTerms=0 behavior?
I hacked my working copy to turn off all the term counting stuff for
demo purposes (diff posted below). We need to more robustly
overhaul it though.
Erik
$ svn diff
Index: java/org/apache/solr/handler/admin/LukeRequestHandler.java
===================================================================
--- java/org/apache/solr/handler/admin/LukeRequestHandler.java
(revision 538798)
+++ java/org/apache/solr/handler/admin/LukeRequestHandler.java
(working copy)
@@ -81,7 +81,7 @@
public static final String NUMTERMS = "numTerms";
public static final String DOC_ID = "docId";
public static final String ID = "id";
- public static final int DEFAULT_COUNT = 10;
+ public static final int DEFAULT_COUNT = 0;
@Override
public void handleRequestBody(SolrQueryRequest req,
SolrQueryResponse rsp) throws Exception
@@ -272,8 +272,11 @@
IndexReader reader = searcher.getReader();
IndexSchema schema = searcher.getSchema();
- // Walk the term enum and keep a priority quey for each map in
our set
- Map<String,TopTermQueue> ttinfo = getTopTerms(reader, fields,
numTerms, null );
+ Map<String,TopTermQueue> ttinfo = null;
+ if (numTerms > 0) {
+ // Walk the term enum and keep a priority quey for each map in
our set
+ ttinfo = getTopTerms(reader, fields, numTerms, null );
+ }
SimpleOrderedMap<Object> finfo = new SimpleOrderedMap<Object>();
Collection<String> fieldNames = reader.getFieldNames
(IndexReader.FieldOption.ALL);
for (String fieldName : fieldNames) {
@@ -288,8 +291,9 @@
f.add( "type", (ftype==null)?null:ftype.getTypeName() );
f.add( "schema", getFieldFlags( sfield ) );
-
- Query q = qp.parse( fieldName+":[* TO *]" );
+
+ // TODO: this could use a constant scoring range query
instead of parsing
+/* Query q = qp.parse( fieldName+":[* TO *]" );
int docCount = searcher.numDocs( q, matchAllDocs );
if( docCount > 0 ) {
// Find a document with this field
@@ -311,16 +315,19 @@
// Find one document so we can get the fieldable
}
f.add( "docs", docCount );
-
- TopTermQueue topTerms = ttinfo.get( fieldName );
- if( topTerms != null ) {
- f.add( "distinct", topTerms.distinctTerms );
-
- // Include top terms
- f.add( "topTerms", topTerms.toNamedList( searcher.getSchema
() ) );
+*/
- // Add a histogram
- f.add( "histogram", topTerms.histogram.toNamedList() );
+ if (ttinfo != null) {
+ TopTermQueue topTerms = ttinfo.get( fieldName );
+ if( topTerms != null ) {
+ f.add( "distinct", topTerms.distinctTerms );
+
+ // Include top terms
+ f.add( "topTerms", topTerms.toNamedList( searcher.getSchema
() ) );
+
+ // Add a histogram
+ f.add( "histogram", topTerms.histogram.toNamedList() );
+ }
}
// Add the field
@@ -333,12 +340,12 @@
private static SimpleOrderedMap<Object> getIndexInfo( IndexReader
reader ) throws IOException
{
// Count the terms
- TermEnum te = reader.terms();
+// TermEnum te = reader.terms();
int numTerms = 0;
- while (te.next()) {
- numTerms++;
- }
-
+// while (te.next()) {
+// numTerms++;
+// }
+
Directory dir = reader.directory();
SimpleOrderedMap<Object> indexInfo = new
SimpleOrderedMap<Object>();
indexInfo.add("numDocs", reader.numDocs());