thanx for the precision.

-neil

-----Original Message-----
From: Doug Cutting [mailto:[EMAIL PROTECTED]
Sent: 13 juin, 2003 13:28
To: Lucene Users List
Subject: Re: How to get field contents


This can be done more efficiently if you only want to enumerate the 
terms of a particular field.  Term enumerations are ordered first by 
field, then by the term text.  You can also specify the initial position 
of a term enumeration.  Thus an efficient enumeration of the terms in 
"myField" can be done with something like:

   IndexReader reader = IndexReader.open("index");
   TermEnum te = reader.terms(new Term("myField", ""));
   while (te.term() != null && "myField".equals(te.term().field())) {
     ... do something silly ...
     te.next();
   }

Doug


Neil Couture wrote:
> As far as I know you will have to go throught the index and verify the 
> field field (that is not an error) of each term:
> 
>                       IndexReader reader      = IndexReader.open("index");
>                       TermEnum        te              = reader.terms(); 
>                       
>                       while ( te.next() ) {
>                               
>                               Term tt = te.term();
>                               
>                               String fieldOfTerm = tt.field();
>                               
>                               if ( fieldOfTerm.compareTo( "contents" ) ) {
> 
>                                       do_something_silly()...
>                               
>                               } else if ( fieldOfTerm.compareTo( "path" ) ) {
> 
>                                       do_something_silly2()...
>                               }
>                       }
> 
> 
> -neil
> 
> 
> 
> 
> -----Original Message-----
> From: Ulrich Mayring [mailto:[EMAIL PROTECTED]
> Sent: 13 juin, 2003 08:14
> To: [EMAIL PROTECTED]
> Subject: How to get field contents
> 
> 
> Hello,
> 
> I'd like to build a list with all values from a certain field that occur 
> in an index. Looking at the API, there's a method getFieldNames(), but I 
> already know the field name, I want to get a list of all the values. 
> Also, I can enumerate fields by giving Terms, but a Term means I have to 
> have the field name and value.
> 
> Can this be done?
> 
> Kind regards,
> 
> Ulrich
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to