lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Willnauer <simon.willna...@googlemail.com>
Subject Re: Read large size index
Date Mon, 29 Jun 2009 16:46:46 GMT
On Mon, Jun 29, 2009 at 6:36 PM, m.harig<m.harig@gmail.com> wrote:
>
> Thanks Simon ,
>
> Hey there, that makes things easier. :)
>
> ok here are some questions:
>
>>>>Do you iterate over all docs calling hits.doc(i) ?If so do you have to
> load all fields to render your results, if not you should not retrieve
> all of them?
>
>
> Yes, am iterating over all docs by calling hits.doc(i) ,
do you really need to get all docs? wouldn't it be enough to fetch
just the top N you want to display or do you want to display all of
them?
>
>
>
> You use IndexSearchersearch(Query q,...) which returns a Hits object
> have you tried to use the new search methods returning TopDocs?
>
> Sorry, i didn't , could you please send me a piece of code.
Example:
  IndexReader open = IndexReader.open("/tmp/testindex/");
    IndexSearcher searcher = new IndexSearcher(open);
    final String fName = "test";
    TopDocs topDocs = searcher.search(new TermQuery(new Term(fName, "lucene")),
        Integer.MAX_VALUE);
    FieldSelector selector = new FieldSelector() {
      public FieldSelectorResult accept(String fieldName) {
        return fieldName == fName ? FieldSelectorResult.LOAD
            : FieldSelectorResult.NO_LOAD;
      }

    };

    final int totalHits = topDocs.totalHits;
    ScoreDoc[] scoreDocs = topDocs.scoreDocs;
    for (int i = 0; i < totalHits; i++) {
      Document doc = searcher.doc(scoreDocs[i].doc, selector);
    }
>
> when you search for pdf and get 30k results you load all the "stored"
> field content into memory once you call IndexSearcher.doc(i) as it
> internally calls IndexReader.document(i, null). This is equivalent to
> a "Load All fields" FieldSelector.
> You can have a closer look at FieldSelector and the new search methods
> which accept them. This is a way to make you retrieval faster and load
> only the fields you really need.
>
>
>
> --
> View this message in context: http://www.nabble.com/Read-large-size-index-tp24251993p24257547.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message