0
votes

I'm using Lucene with java to index some text documents. Now, after I get some top documents for a keyword search, I want to further refine my search and search only those top documents with some additional keywords, so each document once. Can somebody tell me on how I can search a specific document with a specific keyword, not the whole index, but lets say just 123.xml with keywords "bla blah".

thanx in advance

1

1 Answers

0
votes

If you want to refine your search, you should use filters (look at IndexSearcher

search(Query query,
     Filter filter,
     int n,
     Sort sort)

)! Filters will be executed on the result set and are the proper way to implement refined searches.

Have a look at this page to find out how to use filters: http://www.javaranch.com/journal/2009/02/filtering-a-lucene-search.html

Anyway:

If you want to search in just one document you can either take the one document, store it in a RAMDirectory and search in the RAMDirectory just as you would in your normal index. Or you can have a field containig unique identifyers for each document and add this to your query e.g. "contant:(bla blah) and uniqe_doc_id:(doc1)"