We need to update the Blacklight app's catalog_controller file to match the schema fields we added to the Solr schema configuration file.
1. With a FTP program, download Blacklight’s CatalogController file found at
2. Open it in a text editor and begin editing by making the config.default_solr_params array look like:
3. Uncomment the following line (by deleting the hash symbol) so it looks like:
You can change the numbers inside the array if you want to change the options users see for the number of results shown on the screen.
4. Also uncomment the following array so it looks like:
5. Change the following lines:
to:
where "field1_txt" is the name of whichever field you want to show as the title of the individual record.
6. Edit the existing config.add_facet_field lines in the config.add_facet_field section to use your schema's field names:
You can also add label names for the facets and define limits on teh number of facet options displayed. For further customization of the facet fields, see the Blacklight site.
7. Also, to ensure facet fields are shown, make sure that the following line is not commented out:
8. Edit the existing config.add_index_field lines and add fields that you want to display in the results list to the config.add_index_field section:
You can use the link_to_search helper to create a search shortcut. For further customization of this section, see the Blacklight online guide.
9. Edit the existing config.add_show_field lines and add fields to the config.add_show_field section that you want to see displayed in the individual result page:
10. Comment out all lines of the following sections by placing hashtag symbols at the beginning of each line:
11. Edit the existing config.add_sort_field lines to use fieldnames that you would like the user to be able to sort the results:
12. Save the catalog_controller.rb file and use the FTP program to replace the server copy with the copy you just edited.
Previous post: Update Solr schema configuration
Next post: Update Solr's solrconfig file
1. With a FTP program, download Blacklight’s CatalogController file found at
/home/username/public_html/test-app/app/controllers/catalog_controller.rb
2. Open it in a text editor and begin editing by making the config.default_solr_params array look like:
config.default_solr_params = {
qt: 'search',
rows: 10
}
3. Uncomment the following line (by deleting the hash symbol) so it looks like:
config.per_page = [10,20,50,100]
You can change the numbers inside the array if you want to change the options users see for the number of results shown on the screen.
4. Also uncomment the following array so it looks like:
config.default_document_solr_params = {
qt: 'document',
## These are hard-coded in the blacklight 'document' requestHandler
fl: '*',
rows: 1,
q: '{!term f=id v=$id}'
}
5. Change the following lines:
# solr field configuration for search results/index views
config.index.title_field = 'title_display'
config.index.display_type_field = 'format'
# solr field configuration for document/show views
#config.show.title_field = 'title_display'
#config.show.display_type_field = 'format'
to:
# solr field configuration for search results/index views
config.index.title_field = 'field1_txt'
#config.index.display_type_field = 'format'
# solr field configuration for document/show views
config.show.title_field = 'field1_txt'
#config.show.display_type_field = 'format'
where "field1_txt" is the name of whichever field you want to show as the title of the individual record.
6. Edit the existing config.add_facet_field lines in the config.add_facet_field section to use your schema's field names:
config.add_facet_field 'field1Facet', label: 'Field 1', limit: 10
config.add_facet_field 'field2Facet', label: 'Field 2', limit: 15
You can also add label names for the facets and define limits on teh number of facet options displayed. For further customization of the facet fields, see the Blacklight site.
7. Also, to ensure facet fields are shown, make sure that the following line is not commented out:
config.add_facet_fields_to_solr_request!
8. Edit the existing config.add_index_field lines and add fields that you want to display in the results list to the config.add_index_field section:
config.add_index_field 'field2_txt', label: 'Field 2'
config.add_index_field 'field3_txt', label: 'Field 3', link_to_search: 'field3Facet'
You can use the link_to_search helper to create a search shortcut. For further customization of this section, see the Blacklight online guide.
9. Edit the existing config.add_show_field lines and add fields to the config.add_show_field section that you want to see displayed in the individual result page:
config.add_show_field 'field2_txt', label: 'Field 2'
config.add_show_field 'field3_txt', label: 'Field 3'
10. Comment out all lines of the following sections by placing hashtag symbols at the beginning of each line:
config.add_search_field('title') do |field|
# solr_parameters hash are sent to Solr as ordinary url query params.
field.solr_parameters = { :'spellcheck.dictionary' => 'title' }
# :solr_local_parameters will be sent using Solr LocalParams
# syntax, as eg {! qf=$title_qf }. This is neccesary to use
# Solr parameter de-referencing like $title_qf.
# See: http://wiki.apache.org/solr/LocalParams
field.solr_local_parameters = {
qf: '$title_qf',
pf: '$title_pf'
}
end
config.add_search_field('author') do |field|
field.solr_parameters = { :'spellcheck.dictionary' => 'author' }
field.solr_local_parameters = {
qf: '$author_qf',
pf: '$author_pf'
}
end
# Specifying a :qt only to show it's possible, and so our internal automated
# tests can test it. In this case it's the same as
# config[:default_solr_parameters][:qt], so isn't actually neccesary.
config.add_search_field('subject') do |field|
field.solr_parameters = { :'spellcheck.dictionary' => 'subject' }
field.qt = 'search'
field.solr_local_parameters = {
qf: '$subject_qf',
pf: '$subject_pf'
}
end
11. Edit the existing config.add_sort_field lines to use fieldnames that you would like the user to be able to sort the results:
config.add_sort_field 'score desc, field1_txt asc', label: 'Relevance'
config.add_sort_field 'field1_txt asc', label: 'Field 1'
12. Save the catalog_controller.rb file and use the FTP program to replace the server copy with the copy you just edited.
Previous post: Update Solr schema configuration
Next post: Update Solr's solrconfig file
thanks for sharing such details about bigdata and hadoop. Bigdata in hadoop is the interseting topic and to get some important information.Ruby on Rails Online Course
ReplyDelete