Sha256: f45d7d9bd7bb94a2f91d78da31c69e2f9dcbacd301cf7b9f398f39577d4f4e42
Contents?: true
Size: 1.17 KB
Versions: 62
Compression:
Stored size: 1.17 KB
Contents
module Workarea module Search class HelpSearch include Query include Facets include Pagination document Search::Help def self.available_sorts Sort::Collection.new( Sort.relevance, Sort.newest, Sort.name_asc, Sort.name_desc ) end def sanitized_query @sanitized_query ||= QueryString.new(params[:q]).sanitized.presence || '*' end def current_sort self.class.available_sorts.find(params[:sort]) end def query { query_string: { query: sanitized_query, fields: %w(name^1.5 facets^0.75 body), use_dis_max: true } } end def post_filter { bool: { must: facets.map(&:post_filter_clause).reject(&:blank?) } } end def facets @facets ||= [TermsFacet.new(self, 'category')] end def sort if current_sort.field.present? [{ current_sort.field => current_sort.direction }] else [{ _score: :desc }, { created_at: :desc }] end end end end end
Version data entries
62 entries across 62 versions & 1 rubygems