I'm going mostly from memory here, so the details may not be entirely accurate, but.....
See TermDocs (FilterTermDocs?). Use the seek method to get to the term e.g. TermDocs.seek(new Term("specific_field", "")); Note that the "" as the value of the term gets all the terms. Then use TermDocs.next until it returns false. At each point, TermDocs.doc() will give you the Lucene ID of a document containing that term. Really, this enumerates all the documents that have any values in specific_field. One issue here is that you'll get multiple hits per document. For instance, say you've indexed A, B, and C as values in specific_field for document 5. Just blindly doing the next() call will get you document 5 three times. You can use TermDocs.skipTo(current document + 1). to insure that you only process a document once. This is either a minor efficiency or a major time savings, depending on the characteristics of your index..... Be a bit careful and only call next() if you *don't* use skipto, or you may skip a doc that only has one value for specific_field. Hope this helps Erick On 11/12/06, Simon Willnauer <[EMAIL PROTECTED]> wrote:
Hey tony, I guess the easiest way for you to do that is to create a extra field containig the field names and just fire a boolean query on this extra field. best regards simon On 11/12/06, tony yin <[EMAIL PROTECTED]> wrote: > I want search document by specific field, not by field value, How to? > > I have some document store in fields{content, key, path} and some in > {content, key, path, specific_field} > > and I want to find all the document that have specific_field, Could you help > me? > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]