You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by David Neubert <de...@yahoo.com> on 2007/11/08 20:39:39 UTC

Boolean matches in a unique instance of a multi-value field?


Is it possible to find boolean matches (foo AND bar) in a single unique instance of a multi-value field.  So if foo is found in one instance of multi-value field, and is also found in another instance of the multi-value field -- this WOULD NOT be a match, but only if both words are found in the same instance of the multi-value field.

Thanks,

Dave




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Boolean matches in a unique instance of a multi-value field?

Posted by Chris Hostetter <ho...@fucit.org>.
: Is it possible to find boolean matches (foo AND bar) in a single unique 
: instance of a multi-value field.  So if foo is found in one instance of 
: multi-value field, and is also found in another instance of the 
: multi-value field -- this WOULD NOT be a match, but only if both words 
: are found in the same instance of the multi-value field.

The conventional "trick" to this is to use a positionIncrimentGap (and 
option on TextFields) which is larger then any single "sentence" will be, 
then at query time instead of using a boolena query use a sloppy phrase.  
so if you assume "sentences" are never more then 100 words long, use 
positionIncrimentGap=100, and query for "foo bar"~100

since there will be an (emulated) "gap" of 100 terms between each distinct 
sentence value, the only way "foo" will appear within 100 terms of "bar" 
is if they both appear in the same sentence.

for things like sentence:"+foo +(bar baz yak)" you need to use SpanQueries 
instead of PhraseQueries ... which don't have native query parser support 
so you'd need a custom plugin to help with that.

-Hoss