Commit 951544f6b6ced102c9847636dfd71d06a1009d9d
1 parent
0b167531
Exists in
master
and in
19 other branches
Raise ArgumentError if 'missing' option to boost_by used pre-ES 5.0
Showing
2 changed files
with
13 additions
and
5 deletions
Show diff stats
lib/searchkick/query.rb
... | ... | @@ -872,8 +872,12 @@ module Searchkick |
872 | 872 | } |
873 | 873 | } |
874 | 874 | |
875 | - if value[:missing].present? && !below50? | |
876 | - script_score[:field_value_factor].merge!({missing: value[:missing].to_f}) | |
875 | + if value[:missing].present? | |
876 | + if below50? | |
877 | + raise ArgumentError, "Option 'missing' for boost_by supported in Elasticsearch 5 or greater" | |
878 | + else | |
879 | + script_score[:field_value_factor].merge!({missing: value[:missing].to_f}) | |
880 | + end | |
877 | 881 | end |
878 | 882 | |
879 | 883 | { | ... | ... |
test/boost_test.rb
... | ... | @@ -117,8 +117,6 @@ class BoostTest < Minitest::Test |
117 | 117 | end |
118 | 118 | |
119 | 119 | def test_boost_by_missing_field |
120 | - skip if elasticsearch_below50? | |
121 | - | |
122 | 120 | store [ |
123 | 121 | {name: "Tomato A"}, |
124 | 122 | {name: "Tomato B", orders_count: 10}, |
... | ... | @@ -129,7 +127,13 @@ class BoostTest < Minitest::Test |
129 | 127 | assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"], boost_by: {orders_count: {factor: 5}, orders_value: {factor: 5}} |
130 | 128 | end |
131 | 129 | |
132 | - assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"], boost_by: {orders_count: {factor: 5}, orders_value: {factor: 5, missing: 1}} | |
130 | + if elasticsearch_below50? | |
131 | + assert_raises(ArgumentError) do | |
132 | + assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"], boost_by: {orders_count: {factor: 5}, orders_value: {factor: 5, missing: 1}} | |
133 | + end | |
134 | + else | |
135 | + assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"], boost_by: {orders_count: {factor: 5}, orders_value: {factor: 5, missing: 1}} | |
136 | + end | |
133 | 137 | end |
134 | 138 | |
135 | 139 | def test_boost_by_boost_mode_multiply | ... | ... |