lib/elastic_search/query_builder.rb in elasticsearch-query-builder-0.5 vs lib/elastic_search/query_builder.rb in elasticsearch-query-builder-0.6

- old
+ new

@@ -31,12 +31,13 @@ add_clause(internal_path, body) self end end - def initialize(opts: {}, client: nil, function_score: false) + def initialize(opts: {}, mopts: [], client: nil, function_score: false) @opts = opts + @mopts = mopts @function_score = function_score @client = client end def to_json(*_args) @@ -47,12 +48,24 @@ raise 'client: should be set in order to fetch results' unless client client&.search(opts)&.results end + def multisearch_results + raise 'client: should be set in order to fetch multisearch_results' unless client + + client&.msearch(mopts)&.results + end + + def add_to_multisearch(index: {}) + mopts << index + mopts << opts + @opts = {} + end + private - attr_accessor :opts, :client + attr_accessor :opts, :mopts, :client def init_path(path) return if path.size == 1 || initialized?(path) path_minus_one = path.first(path.size - 1)