Commit 3868a25e154d7f72f987a7b07b821add4e3579e8

Authored by Andrew Kane
1 parent d4b3b2c6

Longer phrase matching

lib/searchkick/reindex.rb
@@ -83,7 +83,7 @@ module Searchkick @@ -83,7 +83,7 @@ module Searchkick
83 searchkick_suggest_index: { 83 searchkick_suggest_index: {
84 type: "custom", 84 type: "custom",
85 tokenizer: "standard", 85 tokenizer: "standard",
86 - filter: ["lowercase", "asciifolding", "shingle"] 86 + filter: ["lowercase", "asciifolding", "searchkick_suggest_shingle"]
87 } 87 }
88 }, 88 },
89 filter: { 89 filter: {
@@ -97,6 +97,10 @@ module Searchkick @@ -97,6 +97,10 @@ module Searchkick
97 token_separator: "", 97 token_separator: "",
98 output_unigrams: false, 98 output_unigrams: false,
99 output_unigrams_if_no_shingles: true 99 output_unigrams_if_no_shingles: true
  100 + },
  101 + searchkick_suggest_shingle: {
  102 + type: "shingle",
  103 + max_shingle_size: 5
100 } 104 }
101 }, 105 },
102 tokenizer: { 106 tokenizer: {
test/suggest_test.rb
@@ -13,8 +13,8 @@ class TestSuggest < Minitest::Unit::TestCase @@ -13,8 +13,8 @@ class TestSuggest < Minitest::Unit::TestCase
13 end 13 end
14 14
15 def test_phrase 15 def test_phrase
16 - store_names ["Tiger Shark", "Sharp Teeth", "Sharp Mind"]  
17 - assert_suggest "How to catch a tiger shar", "how to catch a tiger shark" 16 + store_names ["Big Tiger Shark", "Tiger Sharp Teeth", "Tiger Sharp Mind"]
  17 + assert_suggest "How to catch a big tiger shar", "how to catch a big tiger shark"
18 end 18 end
19 19
20 def test_without_option 20 def test_without_option