Skip to content
This repository has been archived by the owner on Dec 6, 2018. It is now read-only.

Commit

Permalink
Add basic fields to catalog controller.
Browse files Browse the repository at this point in the history
  • Loading branch information
redlibrarian committed Jun 3, 2016
1 parent f11581e commit b01cf46
Show file tree
Hide file tree
Showing 4 changed files with 368 additions and 286 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
/log/*
!/log/.keep
/tmp
/jetty/solr/discovery/data

88 changes: 38 additions & 50 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class CatalogController < ApplicationController
#}

# solr field configuration for search results/index views
config.index.title_field = 'title_display'
config.index.display_type_field = 'format'
config.index.title_field = 'title'
#config.index.display_type_field = 'format'

# solr field configuration for document/show views
#config.show.title_field = 'title_display'
Expand Down Expand Up @@ -69,56 +69,44 @@ class CatalogController < ApplicationController
# (useful when user clicks "more" on a large facet and wants to navigate alphabetically across a large set of results)
# :index_range can be an array or range of prefixes that will be used to create the navigation (note: It is case sensitive when searching values)

config.add_facet_field 'format', label: 'Format'
config.add_facet_field 'pub_date', label: 'Publication Year', single: true
config.add_facet_field 'subject_topic_facet', label: 'Topic', limit: 20, index_range: 'A'..'Z'
config.add_facet_field 'language_facet', label: 'Language', limit: true
config.add_facet_field 'lc_1letter_facet', label: 'Call Number'
config.add_facet_field 'subject_geo_facet', label: 'Region'
config.add_facet_field 'subject_era_facet', label: 'Era'

config.add_facet_field 'example_pivot_field', label: 'Pivot Field', :pivot => ['format', 'language_facet']

config.add_facet_field 'example_query_facet_field', label: 'Publish Date', :query => {
:years_5 => { label: 'within 5 Years', fq: "pub_date:[#{Time.zone.now.year - 5 } TO *]" },
:years_10 => { label: 'within 10 Years', fq: "pub_date:[#{Time.zone.now.year - 10 } TO *]" },
:years_25 => { label: 'within 25 Years', fq: "pub_date:[#{Time.zone.now.year - 25 } TO *]" }
}


# Have BL send all facet field names to Solr, which has been the default
# previously. Simply remove these lines if you'd rather use Solr request
# handler defaults, or have no facets.
config.add_facet_fields_to_solr_request!
# config.add_facet_field 'format', label: 'Format'
# config.add_facet_field 'pub_date', label: 'Publication Year', single: true
# config.add_facet_field 'subject_topic_facet', label: 'Topic', limit: 20, index_range: 'A'..'Z'
# config.add_facet_field 'language_facet', label: 'Language', limit: true
# config.add_facet_field 'lc_1letter_facet', label: 'Call Number'
# config.add_facet_field 'subject_geo_facet', label: 'Region'
# config.add_facet_field 'subject_era_facet', label: 'Era'
#
# config.add_facet_field 'example_pivot_field', label: 'Pivot Field', :pivot => ['format', 'language_facet']
#
# config.add_facet_field 'example_query_facet_field', label: 'Publish Date', :query => {
# :years_5 => { label: 'within 5 Years', fq: "pub_date:[#{Time.zone.now.year - 5 } TO *]" },
# :years_10 => { label: 'within 10 Years', fq: "pub_date:[#{Time.zone.now.year - 10 } TO *]" },
# :years_25 => { label: 'within 25 Years', fq: "pub_date:[#{Time.zone.now.year - 25 } TO *]" }
# }
#
#
# # Have BL send all facet field names to Solr, which has been the default
# # previously. Simply remove these lines if you'd rather use Solr request
# # handler defaults, or have no facets.
# config.add_facet_fields_to_solr_request!

# solr fields to be displayed in the index (search results) view
# The ordering of the field names is the order of the display
config.add_index_field 'title_display', label: 'Title'
config.add_index_field 'title_vern_display', label: 'Title'
config.add_index_field 'author_display', label: 'Author'
config.add_index_field 'author_vern_display', label: 'Author'
config.add_index_field 'format', label: 'Format'
config.add_index_field 'language_facet', label: 'Language'
config.add_index_field 'published_display', label: 'Published'
config.add_index_field 'published_vern_display', label: 'Published'
config.add_index_field 'lc_callnum_display', label: 'Call number'
config.add_index_field 'title', label: 'Title'
config.add_index_field 'host', label: 'Host'
config.add_index_field 'crawl_date', label: 'Crawl Date'
config.add_index_field 'content_type', label: 'Content Type'

# solr fields to be displayed in the show (single result) view
# The ordering of the field names is the order of the display
config.add_show_field 'title_display', label: 'Title'
config.add_show_field 'title_vern_display', label: 'Title'
config.add_show_field 'subtitle_display', label: 'Subtitle'
config.add_show_field 'subtitle_vern_display', label: 'Subtitle'
config.add_show_field 'author_display', label: 'Author'
config.add_show_field 'author_vern_display', label: 'Author'
config.add_show_field 'format', label: 'Format'
config.add_show_field 'url_fulltext_display', label: 'URL'
config.add_show_field 'url_suppl_display', label: 'More Information'
config.add_show_field 'language_facet', label: 'Language'
config.add_show_field 'published_display', label: 'Published'
config.add_show_field 'published_vern_display', label: 'Published'
config.add_show_field 'lc_callnum_display', label: 'Call number'
config.add_show_field 'isbn_t', label: 'ISBN'
config.add_show_field 'title', label: 'Title'
config.add_show_field 'url', label: 'URL'
config.add_show_field 'host', label: 'Host'
config.add_show_field 'content_type_served', label: 'Content Type Served'
config.add_show_field 'content_length', label: 'Length'
config.add_show_field 'links_hosts', label: "Link Hosts"
config.add_show_field 'content', label: 'Content'

# "fielded" search configuration. Used by pulldown among other places.
# For supported keys in hash, see rdoc for Blacklight::SearchFields
Expand Down Expand Up @@ -183,10 +171,10 @@ class CatalogController < ApplicationController
# label in pulldown is followed by the name of the SOLR field to sort by and
# whether the sort is ascending or descending (it must be asc or desc
# except in the relevancy case).
config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', label: 'relevance'
config.add_sort_field 'pub_date_sort desc, title_sort asc', label: 'year'
config.add_sort_field 'author_sort asc, title_sort asc', label: 'author'
config.add_sort_field 'title_sort asc, pub_date_sort desc', label: 'title'
# config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', label: 'relevance'
# config.add_sort_field 'pub_date_sort desc, title_sort asc', label: 'year'
# config.add_sort_field 'author_sort asc, title_sort asc', label: 'author'
# config.add_sort_field 'title_sort asc, pub_date_sort desc', label: 'title'

# If there are more than this many search results, no spelling ("did you
# mean") suggestion is offered.
Expand Down
6 changes: 3 additions & 3 deletions config/blacklight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

development:
adapter: solr
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/blacklight-core" %>
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/discovery" %>
test: &test
adapter: solr
url: <%= "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8888}/solr/blacklight-core" %>
url: <%= "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8888}/solr/discovery" %>
production:
adapter: solr
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/blacklight-core" %>
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/discovery" %>
Loading

0 comments on commit b01cf46

Please sign in to comment.