Lucene: Adding search to your application


Lucene: Adding search to your application_第1张图片
Lucene: Adding search to your application_第2张图片
 
 

Directory dir = FSDirectory.open(new File("/path/to/index"));
IndexReader reader = IndexReader.open(dir);
IndexSearcher searcher = new IndexSearcher(reader);
QueryParser parser = new QueryParser(Version.LUCENE_30,"contents",new SimpleAnalyzer());
Query query = parser.parse("+JUNIT +ANT -MOCK");
TopDocs docs = searcher.search(query, 10);

 


Lucene: Adding search to your application_第3张图片
 
Lucene: Adding search to your application_第4张图片
 
Lucene: Adding search to your application_第5张图片
 

 ------------------------------------------------------------------------------------------------------------------------------------

 Lucene scores

 

 

 


Lucene: Adding search to your application_第6张图片
 

 

 

 

你可能感兴趣的:(application)