Module: Blacklight::Searchable

Included in:
Catalog
Defined in:
app/controllers/concerns/blacklight/searchable.rb

Overview

The Searchable module can be included onto classes that need to initialize a SearchService. There are three dependencies you must provide on the including class. Typically these would be provided by Blacklight::Controller

1. search_state
2. blacklight_config
3. search_service_class

Additionally, the including class may override the search_service_context method to provide further context to the SearchService. For example you could override this to provide the currently signed in user.

Instance Method Summary collapse

Instance Method Details

#search_serviceBlacklight::SearchService



15
16
17
# File 'app/controllers/concerns/blacklight/searchable.rb', line 15

def search_service
  search_service_class.new(config: blacklight_config, search_state: search_state, user_params: search_state.to_h, **search_service_context)
end

#search_service_contextHash

Returns a hash of context information to pass through to the search service.

Returns:

  • (Hash)

    a hash of context information to pass through to the search service



20
21
22
# File 'app/controllers/concerns/blacklight/searchable.rb', line 20

def search_service_context
  {}
end

#suggestions_serviceBlacklight::SuggestSearch



25
26
27
# File 'app/controllers/concerns/blacklight/searchable.rb', line 25

def suggestions_service
  Blacklight::SuggestSearch.new(params, search_service.repository).suggestions
end