class Elasticity::Search::Definition
Elasticity::Search::Definition
is a struct that encapsulates all the data specific to one ElasticSearch search.
Attributes
body[RW]
document_types[RW]
index_name[RW]
Public Class Methods
new(index_name, document_types, body, search_args = {})
click to toggle source
# File lib/elasticity/search.rb, line 13 def initialize(index_name, document_types, body, search_args = {}) @index_name = index_name @document_types = document_types @body = body.deep_symbolize_keys! @search_args = search_args end
Public Instance Methods
to_count_args()
click to toggle source
# File lib/elasticity/search.rb, line 24 def to_count_args { index: @index_name, type: @document_types}.tap do |args| body = @body.slice(:query) args[:body] = body if body.present? end end
to_msearch_args()
click to toggle source
# File lib/elasticity/search.rb, line 35 def to_msearch_args search_body = @search_args.merge(@body) { index: @index_name, type: @document_types, search: search_body } end
to_search_args()
click to toggle source
# File lib/elasticity/search.rb, line 31 def to_search_args @search_args.merge({ index: @index_name, type: @document_types, body: @body }) end
update(body_changes)
click to toggle source
# File lib/elasticity/search.rb, line 20 def update(body_changes) self.class.new(@index_name, @document_types, @body.deep_merge(body_changes)) end