-
Notifications
You must be signed in to change notification settings - Fork 254
Configuration Facet Fields
Chris Beer edited this page Feb 1, 2014
·
8 revisions
By default, Blacklight will handle creating the Solr requests to handle the different configuration options below. For performance or other reasons, this behavior can be disabled by removing or commenting out:
config.add_facet_fields_to_solr_request!
Note: When disabled, you are responsible for ensuring Solr returns the necessary values to drive the Blacklight interface.
config.add_facet_field 'format_facet'
- label
config.add_facet_field 'format_facet', label: "Format"
- collapse
config.add_facet_field 'format_facet', collapse: true # the default
config.add_facet_field 'format_facet', collapse: false
- show
config.add_facet_field 'format_facet', show: false # don't display the facet, but configure it in case it displays in the constraints (or e.g. a saved search)
- helper_method
config.add_facet_field 'format_facet', helper_method: :render_format_with_icon
module ApplicationHelper
def render_format_with_icon value
content_tag :span do
content_tag :span, '', class: "glyphicon glyphicon-#{value.parameterize}" +
content_tag :span, value
end
end
end
- partial
config.add_facet_field 'format_facet', partial: 'custom_format_facet'
- single
Only one value can be selected at a time. When the value is selected, the value of this field is ignored when calculating facet counts for this field.
config.add_facet_field 'format_facet', single: true
Single-select facets (above) are one example of Solr's tag/ex functionality. More advanced uses of tag/ex can be done using the tag
and ex
configuration.
config.add_facet_field 'some_field', tag: 'xyz',ex: 'xyz'
config.add_facet_field 'mutually_exclusive_with_above', tag: 'xyz', ex: 'xyz'
config.add_facet_field 'a_query_field', query: {
a_to_n: { label: 'A-N', fq: 'some_field:[A* TO N*]' }
m_to_z: { label: 'M-Z', fq: 'some_field:[A* TO N*]' }
}
config.add_facet_field 'a_pivot_facet', pivot: ['first_field', 'last_field']
config.add_facet_field 'date_format', date: true
blacklight_range_limit