lib/elastics/utility_methods.rb in elastics-client-1.1.11 vs lib/elastics/utility_methods.rb in elastics-client-1.2.0
- old
+ new
@@ -1,15 +1,15 @@
module Elastics
module UtilityMethods
def search(data, vars={})
- Template::Search.new(data).setup(Elastics.elastics).render(vars)
+ Template::Search.new(data, vars).setup(Elastics.elastics).render(vars)
end
# like Elastics.search, but it will use the Elastics::Template::SlimSearch instead
def slim_search(data, vars={})
- Template::SlimSearch.new(data).setup(Elastics.elastics).render(vars)
+ Template::SlimSearch.new(data, vars).setup(Elastics.elastics).render(vars)
end
%w[HEAD GET PUT POST DELETE].each do |m|
class_eval <<-ruby, __FILE__, __LINE__
def #{m}(*args)
@@ -34,10 +34,18 @@
def doc(*args)
elastics.doc(*args)
end
+ def find(pattern)
+ elastics.find(pattern)
+ end
+
+ def usage(*args)
+ elastics.usage(*args)
+ end
+
def scan_search(*args, &block)
elastics.scan_search(*args, &block)
end
def scan_all(*vars, &block)
@@ -47,19 +55,19 @@
end
end
def dump_all(*vars, &block)
refresh_index(*vars)
- scan_all({:params => {:fields => '*,_source'}}, *vars) do |batch|
+ scan_all({:params => {:_source => '*'}}, *vars) do |batch|
batch.map!{|document| document.delete('_score'); document}
block.call(batch)
end
end
# refresh and pull the full document from the index
def dump_one(*vars)
refresh_index(*vars)
- document = search_by_id({:params => {:fields => '*,_source'}}, *vars)
+ document = search_by_id({:params => {:_source => '*'}}, *vars)
document.delete('_score')
document
end
# You should use Elastics.post_bulk_string if you have an already formatted bulk data-string