module Gummi module Document module Search class Filtered include Gummi::Document::Search::Searching attribute :query_string, Gummi::Fields::SanitizedString attribute :terms, Array[Hash], default: [] attribute :query_filters, Array[Hash], default: [] attribute :facets, Hash, default: {} def to_client_args args = {} args[:index] = index args[:type] = type if type args[:from] = from args[:body] = {query: filtered, facets: facets } args end def query {query_string: { query: query_string}} if query_string.present? end def filtered { 'filtered' => { 'query' => query, 'filter' => process_query_filters }} end def process_query_filters if query_filters.length > 1 {and: query_filters} else query_filters.first end end end end end end