Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

\uD83D\uDCD8 Instructions

Info

Highlight important information in a panel like this one. To edit this panel's color or style, select one of the options in the menu.

label = "kb-how-to-article" and type = "page" and space = "samvera"
Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@6f29e17d
sortmodified
showSpacefalse
reversetrue
typepage
labelskb-how-to-article
cql
Table of Contents
Panel
panelIconIdatlassian-info
panelIcon:info:
bgColor#B3D4FF

This tutorial assumes that you generated a work type name GenericWork. If you used a different name, substitute that name for all occurrences of GenericWork and generic_work.

Configure Blacklight to show the property in search results

Optionally, you can configure a property to be shown in the search results for a work.

Edit app/controllers/catalog_controller.rb and look for the section including add_index_field statements. Add the following:

Code Block
config.add_index_field solr_name("contact_email", :stored_searchable), label: "Contact Email"

where…

config.add_index_field

tells BlackLight to add this to the search results.

solr_name("contact_email", :stored_searchable)

tells BlackLight the name of the field in Solr. The solr_name method generates the solr field name according to the indexing set in the property definition in the model. The second parameter should match the indexing specified in the model for the property.

label

tells BlackLight the label to display before the value of the metadata field in search results. By default, the label is the property name (e.g. Contact_email).

See Customizing Blacklight - MeConfigure Blacklight to show the property in search results

Optionally, you can configure a property to be shown in the search results for a work.

Edit app/controllers/catalog_controller.rb and look for the section including add_index_field statements. Add the following:

Code Block
config.add_index_field solr_name("contact_email", :stored_searchable), label: "Contact Email"

where…

config.add_index_field

tells BlackLight to add this to the search results.

solr_name("contact_email", :stored_searchable)

tells BlackLight the name of the field in Solr. The solr_name method generates the solr field name according to the indexing set in the property definition in the model. The second parameter should match the indexing specified in the model for the property.

label

tells BlackLight the label to display before the value of the metadata field in search results. By default, the label is the property name (e.g. Contact_email).

See Customizing Blacklight - Metadata Fields for a tutorial on using the add_index_field method. NOTE: This page of the tutorial also discusses the add_show_field method which is not used in Hyrax show pages. The helper_method which is described in the context of the add_show_field method can also be used with the add_index_field method.

Making the property to the All Fields search

By default, once you add a new property, its values will not be searched. To make sure that your field is searched when the user types a query into a search box, edit app/controllers/catalog_controller.rb and look for the section including add_index_field statements. Add the following:

Code Block
config.add_show_field solr_name("contact_email", :stored_searchable)

where…

config.add_show_field

tells Blacklight to add this to the qf parameter (list of solr fields searched when the user searches “all fields”.

solr_name("contact_email", :stored_searchable)

tells Blacklight the name of the field in Solr.

Alternatively, if you know the official name of the field in Solr, including the suffix that indicates how it is indexed, you can add it to the qf attribute directly. To do this, edit app/controllers/catalog_controller.rb and look for the section beginning with:

Code Block
config.add_search_field('all_fields', label: 'All Fields') do |field|

Add the solr name of your property to the qf line, for example:

Code Block
qf: "#{all_names} file_format_tesim all_text_timv",

Would become:

Code Block
qf: "#{all_names} file_format_tesim all_text_timv contact_email_tesim",

tadata Fields for a tutorial on using the add_index_field method. NOTE: This page of the tutorial also discusses the add_show_field method which is not used in Hyrax show pages. The helper_method which is described in the context of the add_show_field method can also be used with the add_index_field method.

Making the property to the All Fields search

By default, once you add a new property, its values will not be searched. To make sure that your field is searched when the user types a query into a search box, edit app/controllers/catalog_controller.rb and look for the section including add_index_field statements. Add the following:

Code Block
config.add_show_field solr_name("contact_email", :stored_searchable)

where…

config.add_show_field

tells Blacklight to add this to the qf parameter (list of solr fields searched when the user searches “all fields”.

solr_name("contact_email", :stored_searchable)

tells Blacklight the name of the field in Solr.

Alternatively, if you know the official name of the field in Solr, including the suffix that indicates how it is indexed, you can add it to the qf attribute directly. To do this, edit app/controllers/catalog_controller.rb and look for the section beginning with:

Code Block
config.add_search_field('all_fields', label: 'All Fields') do |field|

Add the solr name of your property to the qf line, for example:

Code Block
qf: "#{all_names} file_format_tesim all_text_timv",

Would become:

Code Block
qf: "#{all_names} file_format_tesim all_text_timv contact_email_tesim",