Does anyone know if there's a way using the SOLR query syntax to filter
documents that have only a certain value in a multivalued field?  As an
example if I have some field "country" that's multivalued and I want

q=id:[* TO *]&fq=country:brazil       where 'brazil' is the only value
present.

I've run through a few possibilities to do this, but I think it would be
more common and a better solution would exist:

1) On index creation time, aggregate my source data and create a
"count_country" field that contains the number of terms in the country
field.  Then the query would be q=id:[* TO
*]&fq=country:brazil&fq=count_country=1

2) In the search client, use the terms component to retrieve all terms for
"country" and then do the exclusions in the client and construct the query
as follows q=id:[* TO
*]&fq=country:brazil&fq=-country:canada&fq=-country:us   etc.

3) Write a function query or similar that could capture the info.



Thanks in advance,
Garrett Conaty

Reply via email to