Commit a4d01916f1f304641fdbcf0670633be536f267e5
1 parent
431d633d
Exists in
master
and in
5 other branches
Improved test output [skip ci]
Showing
2 changed files
with
9 additions
and
2 deletions
Show diff stats
lib/searchkick/query.rb
... | ... | @@ -864,10 +864,11 @@ module Searchkick |
864 | 864 | } |
865 | 865 | end |
866 | 866 | |
867 | - # TODO id transformation for arrays | |
868 | 867 | def set_order(payload) |
869 | 868 | order = options[:order].is_a?(Enumerable) ? options[:order] : {options[:order] => :asc} |
870 | 869 | id_field = :_id |
870 | + # TODO no longer map id to _id in Searchkick 5 | |
871 | + # since sorting on _id is deprecated in Elasticsearch | |
871 | 872 | payload[:sort] = order.is_a?(Array) ? order : Hash[order.map { |k, v| [k.to_s == "id" ? id_field : k, v] }] |
872 | 873 | end |
873 | 874 | ... | ... |
test/order_test.rb
... | ... | @@ -11,13 +11,18 @@ class OrderTest < Minitest::Test |
11 | 11 | assert_order "product", ["Product A", "Product B", "Product C", "Product D"], order: "name" |
12 | 12 | end |
13 | 13 | |
14 | + # TODO no longer map id to _id in Searchkick 5 | |
15 | + # since sorting on _id is deprecated in Elasticsearch | |
14 | 16 | def test_id |
15 | 17 | skip if cequel? |
16 | 18 | |
17 | 19 | store_names ["Product A", "Product B"] |
18 | 20 | product_a = Product.where(name: "Product A").first |
19 | 21 | product_b = Product.where(name: "Product B").first |
20 | - assert_order "product", [product_a, product_b].sort_by { |r| r.id.to_s }.map(&:name), order: {id: :asc} | |
22 | + _, stderr = capture_io do | |
23 | + assert_order "product", [product_a, product_b].sort_by { |r| r.id.to_s }.map(&:name), order: {id: :asc} | |
24 | + end | |
25 | + assert_match "Loading the fielddata on the _id field is deprecated", stderr | |
21 | 26 | end |
22 | 27 | |
23 | 28 | def test_multiple |
... | ... | @@ -30,6 +35,7 @@ class OrderTest < Minitest::Test |
30 | 35 | end |
31 | 36 | |
32 | 37 | def test_unmapped_type |
38 | + Product.search_index.refresh | |
33 | 39 | assert_order "product", [], order: {not_mapped: {unmapped_type: "long"}} |
34 | 40 | end |
35 | 41 | ... | ... |