/* * Created on Jun 19, 2003 * * @author Jeff Linwood, jeff@greenninja.com * */ package com.greenninja.lucene; import java.io.IOException; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.queryParser.ParseException; 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 { protected Analyzer analyzer = new StandardAnalyzer(); public Hits search(String indexPath, String queryString) throws IOException, ParseException { //the Lucene index Searcher class, which uses the query on the index IndexSearcher indexSearcher = new IndexSearcher(indexPath); // make the query with our content field, the query string, and the analyzer Query query = QueryParser.parse(queryString,"content",analyzer); Hits hits = indexSearcher.search(query); return hits; } } |