lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r833745 - in /lucene/java/trunk/contrib/benchmark: CHANGES.txt src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
Date Sat, 07 Nov 2009 20:08:01 GMT
Author: mikemccand
Date: Sat Nov  7 20:08:00 2009
New Revision: 833745

URL: http://svn.apache.org/viewvc?rev=833745&view=rev
Log:
LUCENE-2042: add print.hits.field config

Modified:
    lucene/java/trunk/contrib/benchmark/CHANGES.txt
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java

Modified: lucene/java/trunk/contrib/benchmark/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/CHANGES.txt?rev=833745&r1=833744&r2=833745&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/benchmark/CHANGES.txt Sat Nov  7 20:08:00 2009
@@ -4,6 +4,10 @@
 
 $Id:$
 
+11/07/2009
+  LUCENE-2042: Added print.hits.field, to print each hit from the
+  Search* tasks.  (Mike McCandless)
+
 11/04/2009
   LUCENE-2029: Added doc.body.stored and doc.body.tokenized; each
   falls back to the non-body variant as its default.  (Mike McCandless)

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java?rev=833745&r1=833744&r2=833745&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
Sat Nov  7 20:08:00 2009
@@ -51,7 +51,10 @@
  * Otherwise a reader is opened at start and closed at the end.
  * <p>
  * The <code>search.num.hits</code> config parameter sets
- * the top number of hits to collect during searching.
+ * the top number of hits to collect during searching.  If
+ * <code>print.hits.field</code> is set, then each hit is
+ * printed along with the value of that field.</p>
+ *
  * <p>Other side effects: none.
  */
 public abstract class ReadTask extends PerfTask {
@@ -107,6 +110,20 @@
         } else {
           hits = searcher.search(q, numHits);
         }
+
+        final String printHitsField = getRunData().getConfig().get("print.hits.field", null);
+        if (printHitsField != null && printHitsField.length() > 0) {
+          final IndexReader r = searcher.getIndexReader();
+          System.out.println("totalHits = " + hits.totalHits);
+          System.out.println("maxDoc()  = " + r.maxDoc());
+          System.out.println("numDocs() = " + r.numDocs());
+          for(int i=0;i<hits.scoreDocs.length;i++) {
+            final int docID = hits.scoreDocs[i].doc;
+            final Document doc = r.document(docID);
+            System.out.println("  " + i + ": doc=" + docID + " score=" + hits.scoreDocs[i].score
+ " " + printHitsField + " =" + doc.get(printHitsField));
+          }
+        }
+
         //System.out.println("q=" + q + ":" + hits.totalHits + " total hits"); 
 
         if (withTraverse()) {



Mime
View raw message