Sha256: 74b07c0130978ad2184cb1e8927861e6cb8d36295751b2056f998065310107b0

Contents?: true

Size: 687 Bytes

Versions: 1

Compression:

Stored size: 687 Bytes

Contents

module Georgia
  class MediaSearch < SearchDefinition

    def post_process
      filter_by_types
      filter_by_tags
      apply_filtering
    end

    private

    def apply_filtering
      add_filters_to_query if filters.any?
    end

    def filter_by_types
      @types = @params.fetch(:only, [])
      filters << pictures_filter if @types.include?(:pictures)
    end

    def filter_by_tags
      @tags = @params.fetch(:tg, [])
      filters << tags_filter if @tags.any?
    end

    def pictures_filter
      {term: {image?: true}}
    end

    def tags_filter
      {terms: {tag_list: @tags}}
    end

    def query_fields
      ['data_file_name', 'tag_list']
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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