lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Bowesman <...@teamware.com>
Subject Re: question about getting all terms in a section of the documents
Date Wed, 21 Mar 2007 00:12:10 GMT
Donna L Gresh wrote:
> 
> Also, the terms.close()
> statement is outside the scope of terms. I changed to the following, is 
> this correct and should the
> FAQ be changed?
> 
> try
>                 {
>                     TermEnum terms = indexReader.terms(new 
> Term("FIELD-NAME-HERE", ""));
>  
>                     while ("FIELD-NAME-HERE".equals( 
> terms.term().field()))
>                     {
>                      // ... collect enum.term().text() ...
>                 String term = terms.term().text();
>                         System.out.println(term);
>                      if (!terms.next())
>                             break;
>                     }
>                     terms.close();
>                 }

I assume the original reason for the finally block was to demonstrate that the 
TermEnum must be closed, so perhaps it should be

TermEnum terms = null;
try
{
...
}
finally
{
    if (terms != null)
        terms.close();
}

the same applies to TermDocs.  Maybe others?
Antony





---------------------------------------------------------------------
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