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 Marc Sturlese <ma...@gmail.com> on 2009/09/04 10:09:54 UTC

Doubt about Fieldcache.DEFAUL.getStrings[] and Fieldcache.DEFAULT.getStringIndex

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?
Thanks in advance


-- 
View this message in context: http://www.nabble.com/Doubt-about-Fieldcache.DEFAUL.getStrings---and-Fieldcache.DEFAULT.getStringIndex-tp25289618p25289618.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


Re: Doubt about Fieldcache.DEFAUL.getStrings[] and Fieldcache.DEFAULT.getStringIndex

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Fri, Sep 4, 2009 at 4:09 AM, Marc Sturlese<ma...@gmail.com> 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.

-Yonik
http://www.lucidimagination.com

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