diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 3741fc90..ca14206d 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -3,7 +3,6 @@ class CatalogController < ApplicationController include BlacklightRangeLimit::ControllerOverride include Blacklight::Catalog - include Blacklight::Searchable configure_blacklight do |config| # Ensures that JSON representations of Solr Documents can be retrieved using @@ -301,7 +300,7 @@ class CatalogController < ApplicationController # If there are more than this many search results, no spelling ("did you # mean") suggestion is offered. - config.spell_max = 5 + config.spell_max = 25 # Nav actions from Blacklight config.add_nav_action(:bookmark, partial: 'blacklight/nav/bookmark', if: :render_bookmarks_control?) @@ -331,9 +330,6 @@ class CatalogController < ApplicationController # Configuration for autocomplete suggestor config.autocomplete_enabled = true config.autocomplete_path = 'suggest' - # This path is translating to the SOLR endpoint - # not the URL in the dropdown - # config.autocomplete_path = 'select' end def web_services @@ -346,23 +342,4 @@ def web_services end end end - - # def autosearch - # @suggestions = [ - # { - # 'term' => 'serious' - # } - # ] - # render 'autosearch', layout: false - # # end - # We do not need to override this if still using the suggestion service - # and the suggest.html.erb template. Leaving this here in case something - # needs to be changed with processing the results - # def suggest - # # @autoresults = search_service.repository.search(q: params[:q], fq: ['-gbl_suppressed_b: true'], rows: 20, - # # 'facet.field': %w[gbl_resourceClass_sm dct_spatial_sm]) - - # @suggestions = suggestions_service.suggestions - # render 'suggest', layout: false - # end end diff --git a/app/models/concerns/blacklight/suggest/response.rb b/app/models/concerns/blacklight/suggest/response.rb index e626d8d7..12056f09 100644 --- a/app/models/concerns/blacklight/suggest/response.rb +++ b/app/models/concerns/blacklight/suggest/response.rb @@ -23,14 +23,14 @@ def initialize(response, request_params, suggest_path, suggester_name) # present # @return [Array] def suggestions - # (response.dig(suggest_path, suggester_name, request_params[:q], 'suggestions') || []).uniq - suggester_names = %w[spatialSuggester titleSuggester] - suggestion_results = {} - suggester_names.each do |suggester_name| - suggestion_results[suggester_name] = - (response.dig(suggest_path, suggester_name, request_params[:q], 'suggestions') || []).uniq - end - suggestion_results + locations = response.dig(suggest_path, 'spatialSuggester', request_params[:q], 'suggestions') + + # unpack the titles into datasets and maps using their payload value + titles = response.dig(suggest_path, 'titleSuggester', request_params[:q], 'suggestions') + datasets = titles.select { |s| s['payload'] == 'Datasets' } + maps = titles.select { |s| s['payload'] == 'Maps' } + + { locations: locations, datasets: datasets, maps: maps } end end end diff --git a/app/views/catalog/autosearch.html.erb b/app/views/catalog/autosearch.html.erb deleted file mode 100644 index 2ff5b856..00000000 --- a/app/views/catalog/autosearch.html.erb +++ /dev/null @@ -1,37 +0,0 @@ -<% - # We used this to sort the results from an actual search - # This file can be removed if we choose not to use the search option - # Map documents by resource class, and also retrieve locations - data_results = @autoresults.documents.select { |doc| doc['gbl_resourceClass_sm'].include?('Datasets') } - map_results = @autoresults.documents.select { |doc| doc['gbl_resourceClass_sm'].include?('Maps') } - # Location facet values - location_facet = @autoresults['facet_counts']['facet_fields']['dct_spatial_sm'] - location_vals = location_facet.each_slice(2).to_a.map{ |lf| lf[0] } -%> -Locations -<% - l_num = location_vals.length > 3 ? 3: location_vals.length - location_vals.first(l_num).each do |loc| -%> - -<% - end -%> -Datasets -<% - d_num = data_results.length > 3 ? 3: data_results.length - data_results.first(d_num).each do |doc| -%> - -<% - end -%> -Maps -<% - m_num = map_results.length > 3 ? 3: map_results.length - map_results.first(m_num).each do |doc| -%> - -<% - end -%> \ No newline at end of file diff --git a/app/views/catalog/suggest.html.erb b/app/views/catalog/suggest.html.erb index f9c69b66..920cfd53 100644 --- a/app/views/catalog/suggest.html.erb +++ b/app/views/catalog/suggest.html.erb @@ -1,36 +1,26 @@ -<% - spatial_results = @suggestions["spatialSuggester"] - title_results = @suggestions["titleSuggester"] +<% if @suggestions[:locations].length > 0 %> +
  • Locations
  • + <% @suggestions[:locations].first(3).each do |result| %> + + <% end %> +<% end %> -# Map documents by resource class which is saved in payload - data_results = title_results.select { |s| s['payload'] == 'Datasets' } - map_results = title_results.select { |s| s['payload'] == 'Maps' } - -%> -<%= 'Locations' if spatial_results.length > 0 %> -<% - l_num = spatial_results.length > 3 ? 3: spatial_results.length - spatial_results.first(l_num).each do |loc| -%> - -<% - end -%> -<%= 'Datasets' if data_results.length > 0 %> -<% - d_num = data_results.length > 3 ? 3: data_results.length - data_results.first(d_num).each do |data_result| -%> - -<% - end -%> -<%= 'Maps' if map_results.length > 0 %> -<% - m_num = map_results.length > 3 ? 3: map_results.length - map_results.first(m_num).each do |map_result| -%> - -<% - end -%> \ No newline at end of file +<% if @suggestions[:datasets].length > 0 %> +
  • Datasets
  • + <% @suggestions[:datasets].first(3).each do |result| %> + + <% end %> +<% end %> + +<% if @suggestions[:maps].length > 0 %> +
  • Maps
  • + <% @suggestions[:maps].first(3).each do |result| %> + + <% end %> +<% end %> diff --git a/app/views/layouts/catalog_result.html.erb b/app/views/layouts/catalog_result.html.erb index b7d561f4..4c995e44 100644 --- a/app/views/layouts/catalog_result.html.erb +++ b/app/views/layouts/catalog_result.html.erb @@ -8,4 +8,4 @@ <% end %> -<%= render template: "layouts/blacklight/base" %> \ No newline at end of file +<%= render template: "layouts/blacklight/base" %> diff --git a/config/solr_configs/schema.xml b/config/solr_configs/schema.xml index 9f0aa95f..bc617dc6 100644 --- a/config/solr_configs/schema.xml +++ b/config/solr_configs/schema.xml @@ -184,15 +184,6 @@ - - - - diff --git a/config/solr_configs/solrconfig.xml b/config/solr_configs/solrconfig.xml index 9a84a861..6bac262a 100644 --- a/config/solr_configs/solrconfig.xml +++ b/config/solr_configs/solrconfig.xml @@ -205,16 +205,6 @@ - - mySuggester - FuzzyLookupFactory - textSuggest - true - suggest - - - - titleSuggester DocumentDictionaryFactory @@ -224,11 +214,10 @@ title_suggest gbl_resourceClass_sm - - spatialSuggester - FuzzyLookupFactory + DocumentDictionaryFactory + BlendedInfixLookupFactory textSuggest true spatial_suggest @@ -238,7 +227,7 @@ true - 5 + 25 titleSuggester spatialSuggester