Module: Blacklight::SearchFields

Extended by:
Deprecation
Defined in:
app/controllers/concerns/blacklight/search_fields.rb

Overview

Module to deal with accessing (and setting some defaults) in an array of hashes that describe Blacklight search fields. Requires the base class this module is added to implements a #blacklight_config method that returns a hash, where blacklight_config will be an array of hashes describing search fields.

Search Field blacklight_configuration Hash =

:key

“title”, required, unique key used in search URLs to specify search_field

:label

“Title”, # user-displayable label, optional, if not supplied :key.titlecase will be used

:qt

“search”, # Solr qt param, request handler, usually can be left blank; defaults to nil if not explicitly specified

:solr_parameters

{ :qf => “something” } # optional hash of additional parameters to pass to solr for searches on this field.

:solr_local_parameters

{ :qf => “$something” } # optional hash of additional parameters that will be passed using Solr LocalParams syntax, that can use dollar sign to reference other solr variables.

:include_in_simple_select

false. Defaults to true, but you can set to false to have a search field defined for deep-links or BL extensions, but not actually included in the HTML select for simple search choice.

Optionally you can supply a :key, which is what Blacklight will use to identify this search field in HTTP query params. If no :key is supplied, one will be computed from the :label. If that will result in a collision of keys, you should supply one explicitly.

Instance Method Summary collapse

Instance Method Details

#default_search_fieldObject

Deprecated.

Returns default search field, used for simpler display in history, etc. if not set in blacklight_config, defaults to first field listed in #search_field_list



42
43
44
# File 'app/controllers/concerns/blacklight/search_fields.rb', line 42

def default_search_field
  blacklight_config.default_search_field || (Deprecation.silence(Blacklight::SearchFields) { search_field_list.first })
end

#search_field_listObject

Deprecated.

Looks up search field config list from blacklight_config, and 'normalizes' all field config hashes using normalize_config method.



34
35
36
# File 'app/controllers/concerns/blacklight/search_fields.rb', line 34

def search_field_list
  blacklight_config.search_fields.values
end