We are hitting some fun times with facet values.
Imagine your facet values are displayed as check boxes, rather than
links. Now users can select multiple check boxes: They want to see
results that have both English and Spanish items -- which, oddly
enough, translates to a "English OR Spanish" language result.
So, the ultimate query to Solr needs to look something like:
fq=language_facet:(English OR Spanish)
Does RSolr allow this? (Keep reading until the end)
http://jira.projectblacklight.org/jira/browse/CODEBASE-105 notes a
(fixed) bug, whereby facet values were combined with "OR" instead of
with "AND." (I do believe "AND" is the correct default behavior.
However, now I have a use case for "OR".)
I can imagine putting this in the hash of params sent to
Blacklight.solr.find:
solr_params = {
stuff,
"fq" => "language_facet:(English OR Spanish)",
more_stuff
}
BUT - it is further complicated because there can be mulitple fq
parameters in the URL, but a Ruby hash can only cope with a single
instance of a key. For example,
Solr wants:
fq=language_facet:(English OR Spanish)&fq=format:Book
How do we express that in RSolr? Like this?
:phrase_filters => [
"language_facet" => [ "(English OR Spanish)" ],
"format" => "Book"
]
Sometimes, an array and a hash just aren't expressive enough, ya know?
- Naomi
p.s. Are we going to encounter this fun for more Solr goodies in our
future?
I have to speak up and say that one thing I regret about the current
version of solr-ruby is the attribute mangling between the Ruby API
and the Solr parameters. filter_queries => fq It's too much magic
and is confusing when looking at the Solr documentation and seeing fq
and then needing to translate that to the Ruby API.
I believe RSolr makes name pass-through its default, right? But
Blacklight has a special transformation that occurs? (just trying to
understand where phrase_filters/filters comes from below)
Personally, I'd like to see:
:fq => ['title:(something OR "something else")', 'blah AND "blah
blah"', 'category:(this OR that)']
Why have phrase_filters just to add quotes?
Don't get me wrong, making an elegant Ruby API and naming things
clearly is something I really appreciate, but I'd really like to see
less magic in Ruby/Solr glue than more.
One thing to think about is where/how this is going to be used in
Blacklight. In what context? What's the action and the parameters
coming in to it?