module Chewie

Constants

VERSION

Public Instance Methods

build(query: '', filters: {}, options: {}) click to toggle source
# File lib/chewie.rb, line 22
def build(query: '', filters: {}, options: {})
  query_data = set_query_data(query, filters)
  bool_options = options[:bool] || {}

  match_all_query(options) if query_data[:filters].empty?

  context(:query, options) do
    query_context = reduce_handlers(data: query_data)
    bool_context = context(:bool, bool_options) do
      reduce_handlers(data: query_data, context: :bool)
    end

    query_context.merge(bool_context)
  end
end
handlers() click to toggle source
# File lib/chewie.rb, line 15
def handlers
  @handlers ||= {
    query: [],
    bool: []
  }
end

Private Instance Methods

match_all_query(options) click to toggle source
# File lib/chewie.rb, line 42
def match_all_query(options)
  context(:query, options) do
    { match_all: {} }
  end
end