You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by "Monteiro, Alvaro" <Al...@sage.pt> on 2010/04/30 16:47:28 UTC

Negate search

Hi!!

Im using Lucene for simple database indexing. Until now it has been a
breeze. Lucene works great and searching is fast and reliable. However a
problem has shown up.
First of all let me give u an example of how my lucene documents are
organized:

Each document represents an entity that reflects a row on a given
database table.
Imagine the entity Clients. It has the following fields:

'Code', 'Name', 'Address', 'Clients', 'content'.

'content' is the default field. It contains all information.
Clients field has the same content as the 'content' field in order to
allow search for Clients alone.

The problem:
Imagine that in the 'Address' and 'Name' fields contain the word "York".
"York" would be found in 'Clients' and
'content' as well. 

A given user is not allowed to see nor to obtain results from the
'Address' field. If I parse the query and transform
into something like "-Address:writtenquery" i will not obtain any lucene
documents that have that in the 'Address' field. The thing is: if "York"
is also on the 'Name' field, I should get the lucene document because
the user should be able to search that field.

What is the best way to restrict search taking into account this case
scenario?

Thank you so much for your help.

Alvaro