On 6/5/2013 9:03 AM, Dotan Cohen wrote:
> How would one write a query which should perform set union on the
> search terms (term1 OR term2 OR term3), and yet also perform phrase
> matching if both terms are found? I tried a few variants of the
> following, but in every case I am getting set intersection on the
> search terms:
> 
> select?q={!q.op=OR}text:"term1 term2"~100000

A phrase search by definition will require all terms to be present.
Even though it is multiple terms, conceptually it is treated as a single
term.

It sounds like what you are after is what edismax can do.  If you define
the pf field in addition to the qf field, Solr will do something pretty
amazing - it will automatically construct a phrase query from a
non-phrase query and search with it against multiple fields.  Done
correctly, this means that an exact match will be listed first in the
results.

http://wiki.apache.org/solr/ExtendedDisMax#pf_.28Phrase_Fields.29

Thanks,
Shawn

Reply via email to