solrsunspotsunspot-rails

Can I use "-" in FQs using Sunspot gem


I've inherited a Solr installation that doesn't really work for our data. Before re-building, we want to roll out a simple search: filtering on any of our product inventory with size 8, shoe size 9. We have 2 facets, clothing_size, and shoe_size. But, we'd like to get all results of either fq. I can simulate this result accessing query through command string with a "-" before each fq. That works just raw against our Solr server. But our website is implemented with sunspot-rails. And, actually, a gem on top of that for our commerce system.

Question: anyone who is using Sunspot gem, do you have tips for how to add "-" in front of fq field:value elements in the query string?

i.e.

localhost:8982/solr/select?q=*.*&fq=-[shoes_size]=2&fq=-[clothing_size]=8....

(imagined escaped elements)

Thanks


Solution

  • I would imagine a query like this, with one fq parameter. This way the fq parameter functions as an OR instead like an AND when you use multiple fq's:

    localhost:8982/solr/select?q=*.*&fq=-shoes_size:2+-clothing_size:8
    

    http://wiki.apache.org/solr/CommonQueryParameters#fq