concept Searcher in category lucene
appears as: Searcher,
Searcher

This is an excerpt from Manning's book Lucene in Action, Second Edition.
Searcher, like its Indexer sibling, is quite simple and has only a few lines of code dealing with Lucene:
Let’s run Searcher and find documents in our index using the query ‘patent’
% ant Searcher Search an index built using Indexer. Searcher is described in the "Meet Lucene" chapter. Press return to continue... Directory of existing Lucene index built by Indexer: [indexes/MeetLucene] Query: [patent] Running lia.meetlucene.Searcher... Found 8 document(s) (in 11 milliseconds) that matched query 'patent': /Users/mike/lia2e/src/lia/meetlucene/data/cpl1.0.txt /Users/mike/lia2e/src/lia/meetlucene/data/mozilla1.1.txt /Users/mike/lia2e/src/lia/meetlucene/data/epl1.0.txt /Users/mike/lia2e/src/lia/meetlucene/data/gpl3.0.txt /Users/mike/lia2e/src/lia/meetlucene/data/apache2.0.txt /Users/mike/lia2e/src/lia/meetlucene/data/lpgl2.0.txt /Users/mike/lia2e/src/lia/meetlucene/data/gpl2.0.txt /Users/mike/lia2e/src/lia/meetlucene/data/lgpl2.1.txt BUILD SUCCESSFUL Total time: 4 secondsThe output shows that 8 of the 16 documents we indexed with Indexer contain the word patent and that the search took a meager 11 milliseconds. Because Indexer stores files’ absolute paths in the index, Searcher can print them. It’s worth noting that storing the file path as a field was our decision and appropriate in this case, but from Lucene’s perspective, it’s arbitrary metadata included in the indexed documents.