From 744360b75c90dc9372ce3c757a9f88f999b4769c Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 15 Jul 2013 00:29:53 -0700 Subject: [PATCH] Added failing test --- lib/searchkick.rb | 10 +++++----- test/searchkick_test.rb | 11 +++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/searchkick.rb b/lib/searchkick.rb index cdfc2c3..0ae7526 100644 --- a/lib/searchkick.rb +++ b/lib/searchkick.rb @@ -53,7 +53,7 @@ module Searchkick should do match fields, term, boost: 10, operator: "and", analyzer: "searchkick_search" end - should do + must do match fields, term, use_dis_max: false, fuzziness: 0.7, max_expansions: 1, prefix_length: 1, operator: "and", analyzer: "searchkick_search" end if conversions @@ -86,15 +86,15 @@ module Searchkick }, searchkick: { type: "custom", - tokenizer: "standard", + tokenizer: "whitespace", # synonym should come last, after stemming and shingle # shingle must come before snowball - filter: ["standard", "lowercase", "asciifolding", "stop", "snowball", "searchkick_index_shingle"] + filter: ["lowercase", "asciifolding", "stop", "snowball", "searchkick_index_shingle"] }, searchkick_search: { type: "custom", - tokenizer: "standard", - filter: ["standard", "lowercase", "asciifolding", "stop", "snowball", "searchkick_search_shingle"] + tokenizer: "whitespace", + filter: ["lowercase", "asciifolding", "stop", "snowball", "searchkick_search_shingle"] } }, filter: { diff --git a/test/searchkick_test.rb b/test/searchkick_test.rb index 80f5077..24555a7 100644 --- a/test/searchkick_test.rb +++ b/test/searchkick_test.rb @@ -57,6 +57,11 @@ class TestSearchkick < Minitest::Unit::TestCase assert_search "pepperjack cheese", ["Pepper Jack Cheese"] end + def test_middle_token + store_names ["Dish Washer Soap"] + assert_search "dish soap", ["Dish Washer Soap"] + end + # ascii def test_jalapenos @@ -97,13 +102,11 @@ class TestSearchkick < Minitest::Unit::TestCase def test_conversions store [ - {name: "Tomato Sauce", conversions: [{query: "tomato sauce", count: 100}, {query: "tomato", count: 2}]}, + {name: "Tomato Sauce", conversions: [{query: "tomato sauce", count: 5}, {query: "tomato", count: 200}]}, {name: "Tomato Paste", conversions: []}, {name: "Tomatoes", conversions: [{query: "tomato", count: 100}, {query: "tomato sauce", count: 2}]} ] - assert_search "tomato sauce", ["Tomato Sauce", "Tomatoes"] #, "Tomato Paste"] - assert_search "tomato", ["Tomatoes", "Tomato Sauce", "Tomato Paste"] - assert_search "tomato paste", ["Tomato Paste"] #, "Tomatoes", "Tomato Sauce"] + assert_search "tomato", ["Tomato Sauce", "Tomatoes", "Tomato Paste"] end def test_conversions_stemmed -- libgit2 0.21.0