lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anshum <ansh...@gmail.com>
Subject Re: document object
Date Thu, 10 Mar 2011 09:40:54 GMT
Hi Suman,
Do you need to load/use all fields that you have stored in the index? If
that's not the case I'd suggest you to use the


public Document
<http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/document/Document.html>
*doc*(int i, FieldSelector fieldSelector)

http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/search/IndexSearcher.html#doc(int,
org.apache.lucene.document.FieldSelector)
<http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/search/IndexSearcher.html#doc(int,
org.apache.lucene.document.FieldSelector)>function .
This should help you. Also, otherwise if you're using very selective field
which may be used though a FieldCache it'd be a nice thing to do.

Hope that helps.
--
Anshum Gupta
http://ai-cafe.blogspot.com


On Thu, Mar 10, 2011 at 3:01 PM, suman.holani <suman.holani@zapak.co.in>wrote:

>
>
> Hi,
>
>
>
> I am facing the  problem
>
>
>
> The line in the loop is going very slow giving me a performance hit
>
>  for (int i = 0; i < hits.length; ++i) {
>
>
>
>                int docId = hits[i].doc;
>
>                Document d = searcher.doc(docId);  //problem
>
> }
>
>
>
> How can I improve this. Please give me an example of the improved code
>
>
>
> Thanks,
>
> Suman
>
>
>
>
>
> Ps :
>
> In one of post Erick said ..
>
>
>
> this line is really suspicious:
>
> Document document = this.indexReader.document(doc)
>
> From the Javadoc for HitCollector.collect:
>
> Note: This is called in an inner search loop. For good search performance,
> implementations of this method should not call
>
> Searcher.doc(int)<file:///C:/lucene-2.1.0/docs/api/org/apache/lucene/search/
> Searcher.html#doc%28int%29>or
>
> IndexReader.document(int)<file:///C:/lucene-2.1.0/docs/api/org/apache/lucene
> /index/IndexReader.html#document%28int%29>on
> every document number encountered. Doing so can slow searches by an
> order
> of magnitude or more.
>
>
>
>
>
>
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message