lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject Re: question about getting all terms in a section of the documents
Date Mon, 19 Mar 2007 14:57:41 GMT
Donna,

You are correct, "enum" should be "terms".  Could you please modify the FAQ?  You just have
to log into Wiki and edit that page (the edit link is at the bottom).

Thanks,
Otis
 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Simpy -- http://www.simpy.com/  -  Tag  -  Search  -  Share

----- Original Message ----
From: Donna L Gresh <gresh@us.ibm.com>
To: java-user@lucene.apache.org
Sent: Monday, March 19, 2007 9:35:26 AM
Subject: question about getting all terms in a section of the documents

I am a very new user of Lucene, and thus far am amazed at its speed and 
ease of use.
I have a question about something in the FAQ though. I have a need to get 
all
terms in a specific section of the document; I want to create a database 
of term vs
an identifier of the document containing the term. There is a part of the 
FAQ which
answers this directly, and says:
try
{
    TermEnum terms = indexReader.terms(new Term("FIELD-NAME-HERE", ""));
    while ("FIELD-NAME-HERE".equals(enum.term().field()))
    {
        // ... collect enum.term().text() ...

        if (!terms.next())
            break;
    }
}
finally
{
    terms.close();
}

However, this doesn't compile for me; Is "enum" supposed to be "terms"? 
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();
                }



Thanks, and I hope this isn't a crazy question-




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