Different suggest dictionaries for different fields
The solr_parameters config field for defining a search field using config.add_search_field in the catalog controller allows us to specify different spellchecking dictionaries (using the spellcheck.dictionary Solr parameter). However, we cannot do the same for suggest.dictionary. Blacklight will always send a parameter-less query to the /suggest endpoint in Solr.
Would it be possible to allow the dictionary to be defined by the user, so that for example, a "title" field could use a "title" dictionary, an "author" field an "author" dictionary, and so on?
That makes a lot of sense to me. Our first stab at implementing it is pretty basic, and there's obviously room for enhancement.
On the surface, this seems like a relatively simple matter of passing the appropriate parameters through from the view -> javascript -> controller -> service. Here are the relevant bits of code:
- https://github.com/projectblacklight/blacklight/blob/master/app/views/catalog/_search_form.html.erb (the
search_fieldcontrol probably has the data we want) - https://github.com/projectblacklight/blacklight/blob/master/app/assets/javascripts/blacklight/autocomplete.js (no idea, off-hand, how to get bloodhound to pass that information through)
- https://github.com/projectblacklight/blacklight/blob/master/app/controllers/concerns/blacklight/catalog.rb (the
#suggestaction in particular; it seems like we might need to pass theblacklight_configthrough to the model so we can act on it there..) - https://github.com/projectblacklight/blacklight/blob/master/app/models/blacklight/suggest_search.rb (it seems like there's an opportunity to do something more interesting than hard-coding parameters for the index -- maybe using
Blacklight::SearchServiceorBlacklght::SearchBuilder-- and some of the functionality we might get for free.
The analogous behavior for changing search parameters based on the search field is here:
https://github.com/projectblacklight/blacklight/blob/master/lib/blacklight/solr/search_builder_behavior.rb#L45-L48
This seems like (a la facets and fields) there's a backwards compatible way to add this feature (current inplementation only dealing with defaults), so I'm marking 7.x.