Commit 0b167531d559953ddf45f57723e982c45b36b78e

Authored by Jordan Anderson
1 parent def69a7c

Missing param supported >= es 5.0

Showing 2 changed files with 13 additions and 1 deletions   Show diff stats
lib/searchkick/query.rb
... ... @@ -872,7 +872,7 @@ module Searchkick
872 872 }
873 873 }
874 874  
875   - if value[:missing].present?
  875 + if value[:missing].present? && !below50?
876 876 script_score[:field_value_factor].merge!({missing: value[:missing].to_f})
877 877 end
878 878  
... ...
test/boost_test.rb
... ... @@ -114,9 +114,21 @@ class BoostTest < Minitest::Test
114 114 ]
115 115 assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"], boost_by: [:orders_count]
116 116 assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"], boost_by: {orders_count: {factor: 10}}
  117 + end
  118 +
  119 + def test_boost_by_missing_field
  120 + skip if elasticsearch_below50?
  121 +
  122 + store [
  123 + {name: "Tomato A"},
  124 + {name: "Tomato B", orders_count: 10},
  125 + {name: "Tomato C", orders_count: 100}
  126 + ]
  127 +
117 128 assert_raises(Searchkick::InvalidQueryError) do
118 129 assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"], boost_by: {orders_count: {factor: 5}, orders_value: {factor: 5}}
119 130 end
  131 +
120 132 assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"], boost_by: {orders_count: {factor: 5}, orders_value: {factor: 5, missing: 1}}
121 133 end
122 134  
... ...