lib/elastic_search/query_builder.rb in elasticsearch-query-builder-0.6.5 vs lib/elastic_search/query_builder.rb in elasticsearch-query-builder-0.6.6
- old
+ new
@@ -46,22 +46,22 @@
end
def results
raise 'client: should be set in order to fetch results' unless client
- client&.search(opts)&.results
+ client&.search(opts.compact)&.results
end
def multisearch_results
raise 'client: should be set in order to fetch multisearch_results' unless client
client&.msearch(body: mopts)&.dig('responses')
end
def add_to_multisearch(index: {})
mopts << index
- mopts << opts
+ mopts << opts.compact
@opts = {}
end
private
@@ -104,9 +104,10 @@
end
def add_clause(path, body)
return if added?(path, body)
+ body = body.compact
if !root_path?(path) && body.is_a?(Array)
existing_content = opts.dig(*path) || []
opts.dig(*path.first(path.size - 1)).store(path.last, body + existing_content)
elsif root_path?(path)
opts[path.first] = body