Re: Searching using lucene!
Tatu Saloranta <tatu <at> hypermall.net>
2003-04-03 15:00:42 GMT
On Wednesday 02 April 2003 23:45, Gupta, Chandrashekhar (CAP, ELCOE) wrote:
> Hi Guru's
> I have indexed the top level folder in which search is to happen..I have a
> query ..How can I search these indexex so that my search would limit to a
> subfolder inside the top level folder indexed. Is there any API for the
You may need to read all the documentation to fully understand how Lucene
works. It has no concept of folders or even files. It just indexes set of
documents with one or more fields each, and allows for searching based on
contents of one or more of those fields. So in a way, answer is no, there's
no such API. However, implementing what you want is fairly easy with Lucene.
In your case you need to recursively index contents of all the fields, and add
one or more fields detailing actual file hierarchy used to get the files.
One possibility is to store filename in one non-tokenizable field, and then
use prefix query (in addition to actual query you want) to limit results to
just documents that match files in specified directory/ies. The query to
match filename/directory should be made required (not optional) to completely
filter out irrelevant results.
Hope this helps,
-+ Tatu +-
ps. I think your question would really belong to users list, not developers...