mirror of https://github.com/apache/lucene.git
LUCENE-2042: add print.hits.field config
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@833745 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
73944292d4
commit
0e2839b2b2
|
@ -4,6 +4,10 @@ The Benchmark contrib package contains code for benchmarking Lucene in a variety
|
||||||
|
|
||||||
$Id:$
|
$Id:$
|
||||||
|
|
||||||
|
11/07/2009
|
||||||
|
LUCENE-2042: Added print.hits.field, to print each hit from the
|
||||||
|
Search* tasks. (Mike McCandless)
|
||||||
|
|
||||||
11/04/2009
|
11/04/2009
|
||||||
LUCENE-2029: Added doc.body.stored and doc.body.tokenized; each
|
LUCENE-2029: Added doc.body.stored and doc.body.tokenized; each
|
||||||
falls back to the non-body variant as its default. (Mike McCandless)
|
falls back to the non-body variant as its default. (Mike McCandless)
|
||||||
|
|
|
@ -51,7 +51,10 @@ import org.apache.lucene.store.Directory;
|
||||||
* Otherwise a reader is opened at start and closed at the end.
|
* Otherwise a reader is opened at start and closed at the end.
|
||||||
* <p>
|
* <p>
|
||||||
* The <code>search.num.hits</code> config parameter sets
|
* 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.
|
* <p>Other side effects: none.
|
||||||
*/
|
*/
|
||||||
public abstract class ReadTask extends PerfTask {
|
public abstract class ReadTask extends PerfTask {
|
||||||
|
@ -107,6 +110,20 @@ public abstract class ReadTask extends PerfTask {
|
||||||
} else {
|
} else {
|
||||||
hits = searcher.search(q, numHits);
|
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");
|
//System.out.println("q=" + q + ":" + hits.totalHits + " total hits");
|
||||||
|
|
||||||
if (withTraverse()) {
|
if (withTraverse()) {
|
||||||
|
|
Loading…
Reference in New Issue