Sha256: e2d7767103dc4ad1de61fffaaf1dd56fbb2719f6e4e5b3f9732864892a57bcc5

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

module Georgia
  class PageSearch < SearchDefinition

    private

    def post_process
      @type = params[:type]
      filters << pages_filter if @type == 'Georgia::Page'
      add_filters_to_query
    end

    def query_fields
      ['title^5', 'tag_list^3', 'keyword_list^2', 'text', 'excerpt', 'template', 'slug']
    end

    def sort_column
      :updated_at
    end

    def sort_direction
      'desc'
    end

    def pages_filter
      {missing: {field: 'type'}}
    end

    def add_suggestion
      @definition[:suggest] = {
        text: query,
        suggest_title: {
          term: {
            field: 'title.tokenized',
            suggest_mode: 'always'
          }
        },
        suggest_body: {
          term: {
            field: 'text.tokenized',
            suggest_mode: 'always'
          }
        }
      }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
georgia-0.8.0 app/searches/georgia/page_search.rb