You do want to use a QueryFilter. The method you suggest sounds good. Make a field called group with a term for each group it belongs to, a field called user with the users it belongs to etc.

QueryFilter will take a query, i.e. group:managers

Pass the Filter to the search method on your Searcher. The first time you do this you will just be doing a regular search. The benefit will come when you reuse that Filter, as the matching docs will be cached. In Lucene 1.4 you may have to wrap the QueryFilter with a CachingFilter -- I don't remember. QueryFilter caches by default in the latest release.

Ensure you are using the same Searcher as often as possible, because the cache is keyed to the Searcher.

- Mark

[EMAIL PROTECTED] wrote:
I’m currently a bit confused on how to accomplish limiting my search
results in Lucene (v1.4.3 can’t easily upgrade for this project). Hopefully
someone can help point me in the correct direction.

Essentially my application is comprised of several objects, namely User,
Group, and Document (converted to lucene document).
Documents may be assigned to multiple Groups (many-to-many).
Users may be members of multiple groups (many-to-many).
A User’s search should only return Document objects that are assigned to a
group that the user is a member to.

My best guess is when indexing my document I should create a field that
contains all of the given document’s groups’ ids (essentially a space
delimited list of unique Long values converted to strings). Given this, I
will need some way to eliminate results based on the contents of this field
if the searching user is not a member of any of the groups that a document
is in. I’d imagine a long chain of OR and NOT clauses is not the best way
of doing things here. Is this what a QueryFilter is for, if so how do I use
it? I could post parse the results after the search, but I'd imagine lucene
can take care of this more efficiently than I can with a large number of
documents.

Any help would be greatly appreciated.

-Robert

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to