lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <DCutt...@grandcentral.com>
Subject RE: extracting information from an index
Date Fri, 16 Nov 2001 18:50:53 GMT
Please don't email me directly.  Keep Lucene questions on Lucene lists.

> From: Winton Davies [mailto:wdavies@overture.com]
>
> Doug, I had the same question regarding enumerating the documents for 
> accountIDs.
> 
> I dont think I have any field that I can quickly guarantee that a 
> term will work for -- is there anyway I can just do a for i=1 to max 
> doc, get doc(i).accountID ?

If you have an accountId field, then you can enumerate all terms in that
field and, for each such term, enumerate all documents with that term.  This
would look something like:

    TermEnum enum = reader.terms(new Term("accountId", ""));
    try {
      while (enum.term().field().equals("accountId")) {
        String accountId = enum.term().text();
        TermDocs termDocs = reader.termDocs(enum.term());
        try {
          while (termDocs.next()) {
            ... do something with accountId and termDocs.doc() ...
          }
        } finally {
          termDocs.close();
        }
        if (!enum.next()) {
          break;
        }
      }
    } finally {
      enum.close();
    }

Is that what you need?

Doug

--
To unsubscribe, e-mail:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message