-
Notifications
You must be signed in to change notification settings - Fork 257
Advanced Search
Blacklight comes out-of the box with an "Advanced Search" form.
This feature allows you to construct more complex queries by combining conditions in multiple fields, and also to apply multiple facet values (that OR rather than AND).
By default, Blacklight does not show a link to the advanced search form. If you'd like to display it, add the following to your catalog controller:
config.advanced_search.enabled = true
The advanced search form relies on Solr's JSON Query DSL. In order to use these types of queries, you have to configure the relevant fields to include a clause_params
in your catalog controller. For example:
config.add_search_field('title') do |field|
field.solr_parameters = {
'spellcheck.dictionary': 'title',
qf: '${title_qf}',
pf: '${title_pf}'
}
field.clause_params = {
edismax: field.solr_parameters.dup # use the same title fields for advanced title search as for regular title search
}
end
Note: there are some unresolved issues related to the JSON Query DSL with an edismax defType (see conversations on the solr users mailing list from June 2023 and July 2023). In the meantime, the easiest workaround on Solr 7 and 8 is to set your luceneMatchVersion
to 7.1.0 or lower. There is not yet an easy workaround for Solr 9.
The blacklight_advanced_search plugin provides even more capability for composing complex queries.