Sha256: da51f22baf64e8fb942441aba6bc80b7143853f7bb399d5e3e8b4a22293bcb4a

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

# custom SearchBuilder generated by NewspaperWorks; adds behavior to Hyrax::CatalogSearchBuilder:
# - BlacklightAdvancedSearch::AdvancedSearchBuilder, to support /newspapers_search
# - NewspaperWorks::HighlightSearchParams, to support highlighting and snippets in results
# - NewspaperWorks::ExcludeModels, to remove NewspaperTitle, NewspaperContainer,
#     and NewspaperIssue objects from keyword searches
class CustomSearchBuilder < Hyrax::CatalogSearchBuilder
  include BlacklightAdvancedSearch::AdvancedSearchBuilder
  include NewspaperWorks::HighlightSearchParams
  include NewspaperWorks::ExcludeModels

  # :exclude_models and :highlight_search_params must be added after advanced_search
  #   so keyword query input can be properly eval'd
  self.default_processor_chain += [:add_advanced_parse_q_to_solr, :add_advanced_search_to_solr,
                                   :exclude_models, :highlight_search_params]

  # add logic to BlacklightAdvancedSearch::AdvancedSearchBuilder
  # so that date range params are recognized as advanced search
  # rubocop:disable Naming/PredicateName
  def is_advanced_search?
    blacklight_params[:date_start].present? || blacklight_params[:date_end].present? || super
  end
  # rubocop:enable Naming/PredicateName
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
newspaper_works-1.0.1 lib/generators/newspaper_works/templates/custom_search_builder.rb
newspaper_works-1.0.0 lib/generators/newspaper_works/templates/custom_search_builder.rb
newspaper_works-0.1.0 lib/generators/newspaper_works/templates/custom_search_builder.rb