As far as I know, there's no support in Solr for "all words must match in the same value of a multi-valued field".

I agree it would be useful in some cases.

As long as you don't need to do an _actual_ phrase search, you can kind of fake it by using a phrase query, with the query slop set so high that it will encompass the whole field. Just make sure your positionIncrementGap in your solrconfig.xml is higher than your phrase slop, to keep your phrase slop from leaking over into another value of the multi-valued field.

fq="man's friend"~10000
(but url encode the value)

On 3/29/2011 4:57 PM, Brian Lamb wrote:
Hi all,

I have a field set up like this:

<field name="common_names" multiValued="true" type="text" indexed="true"
stored="true" required="false" />

And I have some records:

RECORD1
<arr name="common_names">
   <str>man's best friend</str>
   <str>pooch</str>
</arr>

RECORD2
<arr name="common_names">
   <str>man's worst enemy</str>
   <str>friend to no one</str>
</arr>

Now if I do a search such as:
http://localhost:8983/solr/search/?q=*:*&fq={!q.op=AND df=common_names}man's
friend

Both records are returned. However, I only want RECORD1 returned. I
understand why RECORD2 is returned but how can I structure my query so that
only RECORD1 is returned?

Thanks,

Brian Lamb

Reply via email to