Class: Udongo::Search::Frontend
- Defined in:
- lib/udongo/search/frontend.rb
Overview
The goal of this class is to provide a manipulated version of the filtered index data that we can use in the result set of an autocomplete-triggered search query. See Udongo::Search::Base for more information on how this search functionality is designed.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#search ⇒ Object
This translates the filtered indices into meaningful result objects.
Methods inherited from Base
#class_exists?, #indices, #initialize, #namespace, #result_object, #result_object_exists?
Constructor Details
This class inherits a constructor from Udongo::Search::Base
Instance Method Details
#search ⇒ Object
This translates the filtered indices into meaningful result objects. These require a { label: … value: … } to accommodate jquery-ui.
Note that the result_object#url method is defined in Udongo::Search::ResultObjects::Frontend::Page.
If you return nil in the #url method of a result object, the item will get filtered out of the search results.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/udongo/search/frontend.rb', line 18 def search return [] unless term.valid? ::SearchTerm.create!(locale: controller.locale, term: term.value) indices.map do |index| result = result_object(index) next if result.hidden? || result.unpublished? || result.url.nil? { label: result.label, value: result.url } end.select(&:present?) end |