Skip to content
Jane Sandberg edited this page Aug 2, 2023 · 4 revisions

Blacklight comes out-of the box with an "Advanced Search" form.

image

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).

Configuration

Linking to the form

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

Clause params

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.

Comparison to blacklight_advanced_search

The blacklight_advanced_search plugin provides even more capability for composing complex queries.

Clone this wiki locally