concept count in category lucene

appears as: counts, count, count
Lucene in Action, Second Edition

This is an excerpt from Manning's book Lucene in Action, Second Edition.

The setUp() method first creates a new RAMDirectory, to hold the index.
Next, it creates an IndexWriter on this Directory. We created the getWriter convenience method because we need to get the IndexWriter in many places.
Finally, setUp() iterates over our content, creating a Document and Fields, and then adds the Document to the index.
We create the IndexSearcher and execute a basic single-term query with the specified string, returning the number of documents that matched.
We verify the documents counts according to IndexReader and IndexWriter matches how many documents we added.
  • In addition to specifying how many times a task or task sequence should be repeated, you can specify the target rate in count per second (default) or count per minute. Do this by adding : N : R after the task. For example:
    { AddDoc } : 10000 : 100/sec adds 10,000 documents at a rate of 100 documents per second. Or
    [ AddDoc ]: 10000: 3 adds 10,000 docs in parallel, spawning one thread for each added document, at a rate of three new threads per second.
  • Each task contributes to the records count that’s used for reporting at the end. For example, AddDoc returns 1. Most tasks return count 1, some return count 0, and some return a count greater than 1. Sometimes you don’t want to include the count of a task in your final report. To do that, simply prepend a hyphen before your task. For example, if you use this:
    {"BuildIndex"
    -CreateIndex
    {AddDoc}:10000
    -CloseIndex
    } the report will record exactly 10,000 records, but if you leave the - out, it reports 10,002.