Commit 37f78b59fad7168698c52acb464717f2dd5e5dca
1 parent
9623c51e
Exists in
master
and in
2 other branches
Removed mapping of id to _id with order option [skip ci]
Showing
3 changed files
with
2 additions
and
19 deletions
Show diff stats
CHANGELOG.md
@@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
4 | - Raise error when `search` called on relations | 4 | - Raise error when `search` called on relations |
5 | - Raise `ArgumentError` (instead of warning) for invalid regular expression modifiers | 5 | - Raise `ArgumentError` (instead of warning) for invalid regular expression modifiers |
6 | - Raise `ArgumentError` instead of `RuntimeError` for unknown operators | 6 | - Raise `ArgumentError` instead of `RuntimeError` for unknown operators |
7 | +- Removed mapping of `id` to `_id` with `order` option | ||
7 | - Dropped support for Ruby < 2.6 and Active Record < 5.2 | 8 | - Dropped support for Ruby < 2.6 and Active Record < 5.2 |
8 | - Dropped support for NoBrainer and Cequel | 9 | - Dropped support for NoBrainer and Cequel |
9 | - Dropped support for `faraday_middleware-aws-signers-v4` (use `faraday_middleware-aws-sigv4` instead) | 10 | - Dropped support for `faraday_middleware-aws-signers-v4` (use `faraday_middleware-aws-sigv4` instead) |
lib/searchkick/query.rb
@@ -873,11 +873,7 @@ module Searchkick | @@ -873,11 +873,7 @@ module Searchkick | ||
873 | end | 873 | end |
874 | 874 | ||
875 | def set_order(payload) | 875 | def set_order(payload) |
876 | - order = options[:order].is_a?(Enumerable) ? options[:order] : {options[:order] => :asc} | ||
877 | - id_field = :_id | ||
878 | - # TODO no longer map id to _id in Searchkick 5 | ||
879 | - # since sorting on _id is deprecated in Elasticsearch | ||
880 | - payload[:sort] = order.is_a?(Array) ? order : Hash[order.map { |k, v| [k.to_s == "id" ? id_field : k, v] }] | 876 | + payload[:sort] = options[:order].is_a?(Enumerable) ? options[:order] : {options[:order] => :asc} |
881 | end | 877 | end |
882 | 878 | ||
883 | def where_filters(where) | 879 | def where_filters(where) |
test/order_test.rb
@@ -11,20 +11,6 @@ class OrderTest < Minitest::Test | @@ -11,20 +11,6 @@ class OrderTest < Minitest::Test | ||
11 | assert_order "product", ["Product A", "Product B", "Product C", "Product D"], order: "name" | 11 | assert_order "product", ["Product A", "Product B", "Product C", "Product D"], order: "name" |
12 | end | 12 | end |
13 | 13 | ||
14 | - # TODO no longer map id to _id in Searchkick 5 | ||
15 | - # since sorting on _id is deprecated in Elasticsearch | ||
16 | - def test_id | ||
17 | - store_names ["Product A", "Product B"] | ||
18 | - product_a = Product.where(name: "Product A").first | ||
19 | - product_b = Product.where(name: "Product B").first | ||
20 | - _, stderr = capture_io do | ||
21 | - assert_order "product", [product_a, product_b].sort_by { |r| r.id.to_s }.map(&:name), order: {id: :asc} | ||
22 | - end | ||
23 | - unless Searchkick.server_below?("7.6.0") | ||
24 | - assert_match "Loading the fielddata on the _id field is deprecated", stderr | ||
25 | - end | ||
26 | - end | ||
27 | - | ||
28 | def test_multiple | 14 | def test_multiple |
29 | store [ | 15 | store [ |
30 | {name: "Product A", color: "blue", store_id: 1}, | 16 | {name: "Product A", color: "blue", store_id: 1}, |