<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;

public class Searcher {
	public static void main(String[] args) 
		throws Exception {
		String indexdir = args[0];
		String querystring = args[1];
		
		IndexSearcher searcher = 
			new IndexSearcher(indexdir);
		Query query = QueryParser.parse(querystring, 
				"content", 
				new StandardAnalyzer());
		
		Hits hits = searcher.search(query);
		
		for (int i = 0; i &lt; hits.length() ; i++) {
			Document doc = hits.doc(i);
			System.out.println((i + 1) + ": " 
					+ doc.getField("filename").stringValue() 
					+ " (" + hits.score(i) + ")");
		}
	}
	
}
</pre></body></html>