Method: Lcms::Engine::Search::Repository#apply_filters

Defined in:
app/models/lcms/engine/search/repository.rb

#apply_filters(query, options) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'app/models/lcms/engine/search/repository.rb', line 189

def apply_filters(query, options)
  accepted_filters.each do |filter|
    next unless options[filter]

    filter_term = if options[filter].is_a? Array
                    { terms: { filter => options[filter] } }
                  else
                    { match: { filter => { query: options[filter] } } }
                  end
    query[:query][:bool][:filter] << filter_term
  end
  query
end