lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Elschot <paul.elsc...@xs4all.nl>
Subject Re: What is the difference between these searches?
Date Tue, 09 Nov 2004 22:00:23 GMT
Luke,

On Tuesday 09 November 2004 20:58, you wrote:
> Hi,
> 
> I've implemented a converter to translate our system's internal Query
> objects to Lucene's Query model.
> 
> I recently realized that my implementation of "OR NOT" was not working
> as I would expect and I was wondering if anyone on this list could give
> me some advice.

Could you explain "OR NOT" ? 

Lucene has no provision for matching by being prohibited only. This can
be achieved by indexing something for each document that can be
used in queries to match always, combined with something prohibited
in a query.
But doing this is bad for performance for querying larger nrs of docs.

Lucene's - prefix in queries means AND NOT, ie. the term with the - prefix
prohibits the matching of a document.
 
> I am converting a query that means "foo or not bar" into the following:
> 
> +item_type:xyz +(field_name:foo -field_name:bar)
> 
> This returns only Documents where field_name contains foo. I would
> expect it to return all the Documents where field_name contains foo or
> field_name doesn't contain bar.
> 
> Fiddling around with the Lucene Index Toolbox, I think that this query
> does what I want:
> 
> +item_type:xyz field_name:foo -field_name:bar
> 
> Can someone explain to me why these queries return different results?

A bit dense, but anyway:

Anything prefixed with + is required.
Anything not having + or - prefix is optional and only influences the score.
In case there is nothing required by a + prefix, at least one of the things
without prefix is required.

Regards,
Paul Elschot.


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message