test/suggest_test.rb in searchkick-0.8.5 vs test/suggest_test.rb in searchkick-0.8.6
- old
+ new
@@ -16,10 +16,11 @@
store_names ["Big Tiger Shark", "Tiger Sharp Teeth", "Tiger Sharp Mind"]
assert_suggest "How to catch a big tiger shar", "how to catch a big tiger shark", fields: [:name]
end
def test_without_option
+ store_names ["hi"] # needed to prevent ElasticsearchException - seed 668
assert_raises(RuntimeError){ Product.search("hi").suggestions }
end
def test_multiple_fields
store [
@@ -55,12 +56,17 @@
{name: "Shark"}
]
assert_suggest "shar", "shark", fields: [:name, :unknown]
end
- def test_fields_word_start
+ def test_fields_partial_match
store_names ["Great White Shark", "Hammerhead Shark", "Tiger Shark"]
assert_suggest "How Big is a Tigre Shar", "how big is a tiger shark", fields: [{name: :word_start}]
+ end
+
+ def test_fields_partial_match_boost
+ store_names ["Great White Shark", "Hammerhead Shark", "Tiger Shark"]
+ assert_suggest "How Big is a Tigre Shar", "how big is a tiger shark", fields: [{"name^2" => :word_start}]
end
protected
def assert_suggest(term, expected, options = {})