Commit 76656c6bf9283c9718045b3fa06a6f562a3b5d30
1 parent
4c23cb6b
Exists in
master
and in
21 other branches
Reverted treat _id and id differently - #203
Showing
3 changed files
with
5 additions
and
4 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/index.rb
... | ... | @@ -86,7 +86,6 @@ module Searchkick |
86 | 86 | # stringify fields |
87 | 87 | # remove _id since search_id is used instead |
88 | 88 | source = source.inject({}){|memo,(k,v)| memo[k.to_s] = v; memo}.except("_id") |
89 | - source["id"] ||= search_id(record) | |
90 | 89 | |
91 | 90 | # conversions |
92 | 91 | conversions_field = options[:conversions] | ... | ... |
lib/searchkick/query.rb
... | ... | @@ -195,7 +195,8 @@ module Searchkick |
195 | 195 | |
196 | 196 | # order |
197 | 197 | if options[:order] |
198 | - payload[:sort] = options[:order].is_a?(Enumerable) ? options[:order] : {options[:order] => :asc} | |
198 | + order = options[:order].is_a?(Enumerable) ? options[:order] : {options[:order] => :asc} | |
199 | + payload[:sort] = Hash[ order.map{|k, v| [k.to_s == "id" ? :_id : k, v] } ] | |
199 | 200 | end |
200 | 201 | |
201 | 202 | # filters |
... | ... | @@ -382,6 +383,8 @@ module Searchkick |
382 | 383 | def where_filters(where) |
383 | 384 | filters = [] |
384 | 385 | (where || {}).each do |field, value| |
386 | + field = :_id if field.to_s == "id" | |
387 | + | |
385 | 388 | if field == :or |
386 | 389 | value.each do |or_clause| |
387 | 390 | filters << {or: or_clause.map{|or_statement| {and: where_filters(or_statement)} }} | ... | ... |