Class: Skala::ElasticsearchAdapter::Search::RequestTransformation::AddQuery

Inherits:
Transformator::Transformation::Step
  • Object
show all
Defined in:
lib/skala/elasticsearch_adapter/search/request_transformation/add_query.rb

Instance Method Summary collapse

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/skala/elasticsearch_adapter/search/request_transformation/add_query.rb', line 7

def call
  [source.queries, source.facet_queries].flatten.compact.presence.try(:each) do |_query|
    target["query"] ||= {}
    target["query"]["bool"] ||= {}
    target["query"]["bool"]["must"] ||= []
    target["query"]["bool"]["must_not"] ||= []

    if elasticsearch_query = elasticsearch_query_factory(_query)
      container = _query.exclude ? target["query"]["bool"]["must_not"] : target["query"]["bool"]["must"] 
      container << elasticsearch_query
    end
  end
end