Sha256: 6ec877ef6b7dd7446ec1f5ea9fa91e5b93ef1da2fb6d7b34ea945c2a31559afc

Contents?: true

Size: 809 Bytes

Versions: 34

Compression:

Stored size: 809 Bytes

Contents

module Workarea
  module Search
    class SearchSuggestions
      include Query

      document Search::Storefront

      def results
        response['hits']['hits']
      end

      def sanitized_string
        @sanitized_query ||= QueryString.new(params[:q]).sanitized
      end

      def query
        {
          bool: {
            must: [
              {
                match_phrase_prefix: {
                  'content.name': {
                    query: sanitized_string,
                    max_expansions: 10
                  }
                }
              },
              { term: { 'active.now' => true } }
            ]
          }
        }
      end

      def sort
        { type: :desc }
      end

      def size
        Workarea.config.search_suggestions
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.44 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.43 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.42 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.41 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.40 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.39 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.38 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.37 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.36 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.35 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.34 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.33 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.32 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.31 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.30 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.29 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.28 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.27 app/queries/workarea/search/search_suggestions.rb
workarea-core-3.4.26 app/queries/workarea/search/search_suggestions.rb