lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adviner <eric.advinc...@gmail.com>
Subject Re: How to loop through all the entries for a field
Date Thu, 22 Oct 2009 21:27:59 GMT

nevermind I figured it out.  I did this:

                while ((term = termEnum.Term()) != null)
                {
                    if (!term.Field().Equals("BookTitle"))
                        break;

                    map = new SearchResultMap();
                    map.Title = term.Text();

                    control.Items.Add(map);

                    termEnum.Next();
                }

thanks for all the help

adviner wrote:
> 
> How do you know if your on your last term?  I tried it and it does work
> but continues.  How do you know to check if its the last entry?
> 
> Thanks
> 
> 
> Erick Erickson wrote:
>> 
>> Try something like
>> TermEnum te = IndexReader.terms(new Term("BookTitle", ""));
>> do {
>>     Term term = te.term();
>>     if (! term.field().equals("BookTitle")) break;
>>     System.out.println(term.text());
>> } while (te.next());
>> 
>> 
>> Note that next() will merrily continue beyond the last term for
>> the field "BookTitle", so you have to check that you're still
>> where you want to be.
>> 
>> 
>> Best
>> Erick
>> 
>> On Thu, Oct 22, 2009 at 11:52 AM, adviner <eric.advincula@gmail.com>
>> wrote:
>> 
>>>
>>> I have a field in called BookTitle.  I want to loop through all the
>>> entries
>>> without doing a search.  I just want to get the list of BookTitle's that
>>> is
>>> in this field:
>>>
>>> I tried IndexReader but MaxDocs() doesnt work because it returns
>>> everything
>>> and I have other fields in their which is allot bigger.
>>>
>>>
>>> Sorry i originally posted to the developer site which is wrong place so
>>> i
>>> moved it here
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-to-loop-through-all-the-entries-for-a-field-tp26012512p26012512.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
>>>
>>>
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-loop-through-all-the-entries-for-a-field-tp26012512p26017525.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


Mime
View raw message