You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by jacky <ja...@gmail.com> on 2006/09/05 11:57:07 UTC
IndexSearcher executed concurrently
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
Re: IndexSearcher executed concurrently
Posted by jacky <ja...@gmail.com>.
Oh, that is great! I didn't notice this javadoc. Maybe i need to
update my lucene lib.
I had thought one user requests his query, other queries maybe impact
on the result since using a single IndexSearcher. Forget these mails.
Thanks a lot..
On 9/5/06, karl wettin <ka...@gmail.com> wrote:
>
> On Tue, 2006-09-05 at 17:57 +0800, jacky wrote:
> > 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.
>
> I'm afraid I don't understand your questions. What do you mean by "the
> right results"? Perhaps this quote from the javadocs is what you are
> looking for: For performance reasons it is recommended to open only one
> IndexSearcher and use it for all of your searches.
>
>
> http://lucene.apache.org/java/docs/api/org/apache/lucene/search/IndexSearcher.html
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
--
Best Regards.
jacky
Re: IndexSearcher executed concurrently
Posted by karl wettin <ka...@gmail.com>.
On Tue, 2006-09-05 at 17:57 +0800, jacky wrote:
> 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.
I'm afraid I don't understand your questions. What do you mean by "the
right results"? Perhaps this quote from the javadocs is what you are
looking for: For performance reasons it is recommended to open only one
IndexSearcher and use it for all of your searches.
http://lucene.apache.org/java/docs/api/org/apache/lucene/search/IndexSearcher.html
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org