lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yonik Seeley <>
Subject Re: Doubt about Fieldcache.DEFAUL.getStrings[] and Fieldcache.DEFAULT.getStringIndex
Date Sat, 05 Sep 2009 17:26:58 GMT
On Fri, Sep 4, 2009 at 4:09 AM, Marc Sturlese<> wrote:
> Hey there, I am iterating over a DocSet and for every id I neew to get the
> value of a field wich is analyzed with KeyworddAnalyzer and is not sored.
> I have noticed to ways of doing it using Fieldcache. Can someone pleas
> explain me the pros and contras of using one or another?
> Using StringIndex:
> private FieldCache.StringIndex myIndex;
> myIndex = FieldCache.DEFAULT.getStringIndex(searcher.getReader(),
> fieldName);
> //for every docId...
>    int currentId = i.nextDoc();
>    String fieldValue = myIndex.lookup[myIndex.order[currentId]];
> //}
> Using getStrings:
> String[] values = FieldCache.DEFAULT.getStrings(searcher.getReader(),
> fieldName);
> //for every docId...
>    int currentId = i.nextDoc();
>    String fieldValue = values[currentId];
> //}
> Would be true to say that if the terms are repeated many times in that index
> field is better to use my first option but if the terms are never repeated
> it doesn't matter to use the first or the second one?

Pretty much... *if* this field isn't used for anything else.
If you use this field for something else that asks for FieldCache
instances like sorting or faceting, then the StringIndex would be used
and you would be best served by reusing that.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message