Commit 6522ba3b35589abc09bf4b36a5f5bb5c335e7d40
1 parent
96733e00
Exists in
master
and in
21 other branches
Treat _id and id differently - closes #203
Showing
4 changed files
with
5 additions
and
6 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/index.rb
... | ... | @@ -83,7 +83,8 @@ module Searchkick |
83 | 83 | source = record.search_data |
84 | 84 | |
85 | 85 | # stringify fields |
86 | - source = source.inject({}){|memo,(k,v)| memo[k.to_s] = v; memo}.except("id", "_id") | |
86 | + source = source.inject({}){|memo,(k,v)| memo[k.to_s] = v; memo}.except("_id") | |
87 | + source["id"] ||= search_id(record) | |
87 | 88 | |
88 | 89 | options = record.class.searchkick_options |
89 | 90 | ... | ... |
lib/searchkick/query.rb
... | ... | @@ -195,8 +195,7 @@ module Searchkick |
195 | 195 | |
196 | 196 | # order |
197 | 197 | if options[:order] |
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] } ] | |
198 | + payload[:sort] = options[:order].is_a?(Enumerable) ? options[:order] : {options[:order] => :asc} | |
200 | 199 | end |
201 | 200 | |
202 | 201 | # filters |
... | ... | @@ -383,8 +382,6 @@ module Searchkick |
383 | 382 | def where_filters(where) |
384 | 383 | filters = [] |
385 | 384 | (where || {}).each do |field, value| |
386 | - field = :_id if field.to_s == "id" | |
387 | - | |
388 | 385 | if field == :or |
389 | 386 | value.each do |or_clause| |
390 | 387 | filters << {or: or_clause.map{|or_statement| {and: where_filters(or_statement)} }} | ... | ... |
lib/searchkick/results.rb