hi,
The source code in the end is the class to search sth.
1. I wander if concurrent users can get the right results with different
queries since the class has only one IndexSearcher instance.
2. As we know, a new IndexSearcher can be created when user request his
query. If first method gets the right
result, so, which method can get better performance.
public class MySearcher{
private Searcher indexSearcher = new IndexSearcher("indexPath");
private QueryParser parser = new QueryParser("content", new
StandardAnalyzer());
public Document[] search(String queryLine){
Hits hits = indexSearcher.search(parser.parse(queryLine));
Document docs = new Document[hits.length()];
for(int i = 0; i < hits.length(); i ++){
docs[i] = hits.doc(i);
}
return docs;
}
Thanks for you help!
Best Regards.
jacky