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| -%> -