lib/mongoid/elasticsearch/es.rb in mongoid-elasticsearch-0.2.1 vs lib/mongoid/elasticsearch/es.rb in mongoid-elasticsearch-0.3.0
- old
+ new
@@ -27,30 +27,32 @@
per_page = options[:per_page]
query[:size] = ( per_page.to_i ) if per_page
query[:from] = ( page.to_i <= 1 ? 0 : (per_page.to_i * (page.to_i-1)) ) if page && per_page
- Response.new(client, query.merge(type_options(true)), false, klass, klass.es_wrapper, options)
+ options[:wrapper] ||= klass.es_wrapper
+
+ Response.new(client, query.merge(type_options), false, klass, options)
end
- def options_for(obj, escape = false)
- {id: obj.id.to_s}.merge type_options(escape)
+ def all(options = {})
+ search({body: {query: {match_all: {}}}}, options)
end
- def type_options(escape = false)
- {index: index.name, type: escape ? Utils.escape(index.type) : index.type}
+ def options_for(obj)
+ {id: obj.id.to_s}.merge type_options
end
- def index_item(obj)
- client.index({body: obj.as_indexed_json}.merge(options_for(obj, true)))
+ def type_options
+ {index: index.name, type: index.type}
end
- def remove_item(obj)
- client.delete(options_for(obj, true).merge(ignore: 404))
+ def index_item(obj)
+ client.index({body: obj.as_indexed_json}.merge(options_for(obj)))
end
- def all(options = {})
- search({match_all: {}}, options)
+ def remove_item(obj)
+ client.delete(options_for(obj).merge(ignore: 404))
end
def completion_supported?
@version > Gem::Version.new('0.90.2')
end