Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
Resolves #8; Configure default requestHandler
Browse files Browse the repository at this point in the history
* Configure default -- select -- requestHandler
* Clean-up commented out code in catalog_controller
* There is probably a better way to do this
* Might as well cut a first release of the gem
  • Loading branch information
ruebot committed Aug 17, 2017
1 parent d5972cb commit 6f71a16
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 55 deletions.
78 changes: 25 additions & 53 deletions lib/generators/warclight/templates/catalog_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

class CatalogController < ApplicationController

include Blacklight::Catalog
include Warclight::Catalog

Expand All @@ -20,35 +19,11 @@ class CatalogController < ApplicationController
rows: 10
}

# solr path which will be added to solr base url before the other solr params.
#config.solr_path = 'select'

# items to show per page, each number in the array represent another option to choose from.
#config.per_page = [10,20,50,100]

## Default parameters to send on single-document requests to Solr. These settings are the Blackligt defaults (see SearchHelper#solr_doc_params) or
## parameters included in the Blacklight-jetty document requestHandler.
#
#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}'
#}

# solr field configuration for search results/index views
config.index.title_field = 'title'
#config.index.display_type_field = 'level_ssm'
#config.index.thumbnail_field = 'thumbnail_path_ss'

# solr field configuration for document/show views
#config.show.title_field = 'title_display'
#config.show.display_type_field = 'format'
#config.show.thumbnail_field = 'thumbnail_path_ss'

# solr fields that will be treated as facets by the blacklight application
# The ordering of the field names is the order of the display
# The ordering of the field names is the order of the display
#
# Setting a limit will trigger Blacklight's 'more' facet values link.
# * If left unset, then all facet values returned by solr will be displayed.
Expand All @@ -67,17 +42,20 @@ class CatalogController < ApplicationController
# :show may be set to false if you don't want the facet to be drawn in the
# facet bar
#
# set :index_range to true if you want the facet pagination view to have facet prefix-based navigation
# (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 'content_type_norm', label: "General Content Type", collapse: false
config.add_facet_field 'crawl_years', label: "Crawl Years", collapse: false
config.add_facet_field 'domain', label: "Domain"
config.add_facet_field 'links_domains', label: "Links Domains"
config.add_facet_field 'institution', label: "Institution"
config.add_facet_field 'collection_name', label: "Collection Name"
config.add_facet_field 'collection_number', label: "Collection Number"
# set :index_range to true if you want the facet pagination view to have
# facet prefix-based navigation (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 'content_type_norm', label: 'General Content Type', collapse: false
config.add_facet_field 'crawl_year', label: 'Crawl Year', collapse: false
config.add_facet_field 'public_suffix', label: 'Public Suffix', collapse: false
config.add_facet_field 'domain', label: 'Domain'
config.add_facet_field 'links_domains', label: 'Links Domains'
config.add_facet_field 'institution', label: 'Institution'
config.add_facet_field 'collection_name', label: 'Collection Name'
config.add_facet_field 'collection_number', label: 'Collection Number'

# 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
Expand All @@ -91,19 +69,23 @@ class CatalogController < ApplicationController
config.add_index_field 'crawl_date', label: 'Crawl Date'
config.add_index_field 'content_type', label: 'Content Type'
config.add_index_field 'domain', label: 'Domain'
config.add_index_field 'links_domains', label: "This page links to"
config.add_index_field 'institution', label: "Institution"
config.add_index_field 'collection_name', label: "Collection Name"
config.add_index_field 'collection_number', label: "Collection Number"
config.add_index_field 'links_domains', label: 'This page links to'
config.add_index_field 'institution', label: 'Institution'
config.add_index_field 'collection_name', label: 'Collection Name'
config.add_index_field 'collection_number', label: 'Collection Number'

# 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', label: 'Title'
config.add_show_field 'url', label: 'URL'
config.add_show_field 'host', label: 'Host'
config.add_show_field 'crawl_date', label: 'Crawl Date'
config.add_show_field 'source_file', label: 'Source File'
config.add_show_field 'content_type', label: 'Content Type'
config.add_show_field 'server', label: 'Server'
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 'links_hosts', label: 'Link Hosts'
config.add_show_field 'content', label: 'Content'

# "fielded" search configuration. Used by pulldown among other places.
Expand All @@ -127,24 +109,14 @@ class CatalogController < ApplicationController
field.include_in_simple_select = true
end

config.add_search_field 'within_collection' do |field|
field.include_in_simple_select = false
field.solr_parameters = {
fq: '-level_sim:Collection'
}
end

# Field-based searches. We have registered handlers in the Solr configuration
# so we have Blacklight use the `qt` parameter to invoke them
#config.add_search_field 'keyword', label: 'Keyword' do |field|
# field.qt = 'search' # default
#end

# "sort results by" select (pulldown)
# 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, title_sort asc', label: 'relevance'
config.add_sort_field 'score desc', label: 'relevance'

# If there are more than this many search results, no spelling ("did you
# mean") suggestion is offered.
Expand Down
2 changes: 1 addition & 1 deletion solr/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<schema name="ukwa" version="1.6">
<fields>
<field name="id" type="string" indexed="true" stored="false" required="true" multiValued="false" docValues="true"/>
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" docValues="true"/>
<field name="_version_" type="long" indexed="true" docValues="true"/>
<field name="_root_" type="string" indexed="true" docValues="true" />
<field name="_text_" type="text_general" indexed="true" stored="false" multiValued="true"/>
Expand Down
9 changes: 8 additions & 1 deletion solr/conf/solrconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,14 @@
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="fl">*</str>
<str name="q.alt">*:*</str>
<str name="defType">dismax</str>
<str name="facet">on</str>
<str name="facet.mincount">1</str>
<str name="facet.limit">10</str>
<str name="qf">access_terms author category collection collection_name collection_number collections comments content content_encoding content_ffb content_first_bytes content_language content_length content_metadata content_metadata_ss content_text_length content_type content_type_droid content_type_ext content_type_full content_type_norm content_type_served content_type_tika content_type_version crawl_date crawl_dates crawl_year crawl_year_month crawl_year_month_day crawl_years description domain elements_used generator hash hashes host host_surt id_long image_colours image_dominant_colour image_faces image_faces_count image_height image_size image_width institution keywords last_modified last_modified_year license_url links links_domains links_hosts links_hosts_surts links_norm links_public_suffixes locations parse_error pdf_pdfa_errors pdf_pdfa_is_valid postcode postcode_district public_suffix publication_date publication_year record_type referrer_url resourcename sentiment sentiment_score server source_file source_file_offset status_code subject text title type url url_norm url_path url_type wayback_date wct_agency wct_collections wct_description wct_instance_id wct_subjects wct_target_id wct_titlexml_root_ns</str>

<!-- <str name="df">text</str> -->
</lst>
<!-- In addition to defaults, "appends" params can be specified
Expand Down Expand Up @@ -812,7 +820,6 @@
</lst>
</requestHandler>


<!-- A Robust Example
This example SearchHandler declaration shows off usage of the
Expand Down

0 comments on commit 6f71a16

Please sign in to comment.