Class: SiteSearch::PublicationsAdapter
- Inherits:
-
Object
- Object
- SiteSearch::PublicationsAdapter
- Includes:
- Service
- Defined in:
- app/services/site_search/publications_adapter.rb
Overview
Searches our own publication catalogue — the PDFs, manuals, datasheets and
wiring diagrams Swiftype has never indexed.
This is the half of site search we already owned; it moves here unchanged in
behaviour (Item#wild_search, pg_search tsearch + trigram, scoped to the
locale's store) so that Query can treat both engines alike.
Defined Under Namespace
Classes: Result
Constant Summary collapse
- PER_PAGE =
Matches the engine's page size so a blended page draws evenly from both.
10
Instance Method Summary collapse
-
#call ⇒ Result
One page of matching publications.
Methods included from Service
#attributes_used, #build_result, call, #logger
Methods included from Service::Initializer
Instance Method Details
#call ⇒ Result
Returns one page of matching publications.
30 31 32 33 34 35 36 37 |
# File 'app/services/site_search/publications_adapter.rb', line 30 def call # pg_search raises on a blank query rather than returning nothing. return empty if query.blank? Result.new(items: pagy.records(scope).map { |publication| to_item(publication) }, pagy:) rescue PgSearch::EmptyQueryError empty end |