lib/mongoid/elasticsearch/es.rb in mongoid-elasticsearch-0.8.2 vs lib/mongoid/elasticsearch/es.rb in mongoid-elasticsearch-0.8.3

- old
+ new

@@ -43,25 +43,33 @@ if query.is_a?(String) query = {q: Utils.clean(query)} end page = options[:page] - per_page = options[:per_page] + per_page = options[:per_page].nil? ? options[:per] : 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 options[:wrapper] ||= klass.es_wrapper - Response.new(client, query.merge(type_options), false, klass, options) + Response.new(client, query.merge(custom_type_options(options)), false, klass, options) end def all(options = {}) search({body: {query: {match_all: {}}}}, options) end def options_for(obj) {id: obj.id.to_s}.merge type_options + end + + def custom_type_options(options) + if !options[:include_type].nil? && options[:include_type] == false + {index: index.name} + else + type_options + end end def type_options {index: index.name, type: index.type} end