searchkick 1.5.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -13
- data/CHANGELOG.md +15 -0
- data/README.md +21 -54
- data/lib/searchkick.rb +2 -3
- data/lib/searchkick/index.rb +12 -18
- data/lib/searchkick/index_options.rb +5 -25
- data/lib/searchkick/model.rb +25 -44
- data/lib/searchkick/query.rb +135 -297
- data/lib/searchkick/results.rb +0 -4
- data/lib/searchkick/version.rb +1 -1
- data/searchkick.gemspec +4 -4
- data/test/aggs_test.rb +2 -6
- data/test/autocomplete_test.rb +3 -3
- data/test/boost_test.rb +0 -22
- data/test/index_test.rb +6 -12
- data/test/inheritance_test.rb +2 -2
- data/test/match_test.rb +0 -3
- data/test/query_test.rb +1 -2
- data/test/reindex_test.rb +25 -0
- data/test/sql_test.rb +16 -64
- data/test/test_helper.rb +3 -38
- metadata +9 -14
- data/lib/searchkick/reindex_job.rb +0 -26
- data/test/dangerous_reindex_test.rb +0 -27
- data/test/facets_test.rb +0 -90
- data/test/reindex_job_test.rb +0 -31
data/lib/searchkick/results.rb
CHANGED
data/lib/searchkick/version.rb
CHANGED
data/searchkick.gemspec
CHANGED
@@ -13,16 +13,16 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/ankane/searchkick"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split(
|
17
|
-
spec.executables = spec.files.grep(%r{^
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "activemodel"
|
21
|
+
spec.add_dependency "activemodel", ">= 4.1"
|
22
22
|
spec.add_dependency "elasticsearch", ">= 1"
|
23
23
|
spec.add_dependency "hashie"
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "bundler"
|
26
26
|
spec.add_development_dependency "rake"
|
27
27
|
spec.add_development_dependency "minitest"
|
28
28
|
end
|
data/test/aggs_test.rb
CHANGED
@@ -42,7 +42,7 @@ class AggsTest < Minitest::Test
|
|
42
42
|
agg = Product.search("Product", aggs: {store_id: {limit: 1}}).aggs["store_id"]
|
43
43
|
assert_equal 1, agg["buckets"].size
|
44
44
|
# assert_equal 3, agg["doc_count"]
|
45
|
-
assert_equal(1, agg["sum_other_doc_count"])
|
45
|
+
assert_equal(1, agg["sum_other_doc_count"])
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_ranges
|
@@ -110,11 +110,7 @@ class AggsTest < Minitest::Test
|
|
110
110
|
}
|
111
111
|
).aggs
|
112
112
|
|
113
|
-
|
114
|
-
assert_equal 2, aggs["products_per_year"]["buckets"].size
|
115
|
-
else
|
116
|
-
assert_equal 4, aggs["products_per_year"]["buckets"].size
|
117
|
-
end
|
113
|
+
assert_equal 4, aggs["products_per_year"]["buckets"].size
|
118
114
|
end
|
119
115
|
|
120
116
|
protected
|
data/test/autocomplete_test.rb
CHANGED
@@ -3,17 +3,17 @@ require_relative "test_helper"
|
|
3
3
|
class AutocompleteTest < Minitest::Test
|
4
4
|
def test_autocomplete
|
5
5
|
store_names ["Hummus"]
|
6
|
-
assert_search "hum", ["Hummus"],
|
6
|
+
assert_search "hum", ["Hummus"], match: :text_start
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_autocomplete_two_words
|
10
10
|
store_names ["Organic Hummus"]
|
11
|
-
assert_search "hum", [],
|
11
|
+
assert_search "hum", [], match: :text_start
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_autocomplete_fields
|
15
15
|
store_names ["Hummus"]
|
16
|
-
assert_search "hum", ["Hummus"],
|
16
|
+
assert_search "hum", ["Hummus"], match: :text_start, fields: [:name]
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_text_start
|
data/test/boost_test.rb
CHANGED
@@ -14,8 +14,6 @@ class BoostTest < Minitest::Test
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_multiple_conversions
|
17
|
-
skip if elasticsearch_below14?
|
18
|
-
|
19
17
|
store [
|
20
18
|
{name: "Speaker A", conversions_a: {"speaker" => 1}, conversions_b: {"speaker" => 6}},
|
21
19
|
{name: "Speaker B", conversions_a: {"speaker" => 2}, conversions_b: {"speaker" => 5}},
|
@@ -64,26 +62,6 @@ class BoostTest < Minitest::Test
|
|
64
62
|
assert_order "product", ["Product Conversions", "Product Boost"], boost: "orders_count"
|
65
63
|
end
|
66
64
|
|
67
|
-
def test_user_id
|
68
|
-
store [
|
69
|
-
{name: "Tomato A"},
|
70
|
-
{name: "Tomato B", user_ids: [1, 2, 3]},
|
71
|
-
{name: "Tomato C"},
|
72
|
-
{name: "Tomato D"}
|
73
|
-
]
|
74
|
-
assert_first "tomato", "Tomato B", user_id: 2
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_personalize
|
78
|
-
store [
|
79
|
-
{name: "Tomato A"},
|
80
|
-
{name: "Tomato B", user_ids: [1, 2, 3]},
|
81
|
-
{name: "Tomato C"},
|
82
|
-
{name: "Tomato D"}
|
83
|
-
]
|
84
|
-
assert_first "tomato", "Tomato B", personalize: {user_ids: 2}
|
85
|
-
end
|
86
|
-
|
87
65
|
def test_boost_fields
|
88
66
|
store [
|
89
67
|
{name: "Red", color: "White"},
|
data/test/index_test.rb
CHANGED
@@ -12,7 +12,7 @@ class IndexTest < Minitest::Test
|
|
12
12
|
old_index.create
|
13
13
|
different_index.create
|
14
14
|
|
15
|
-
Product.clean_indices
|
15
|
+
Product.searchkick_index.clean_indices
|
16
16
|
|
17
17
|
assert Product.searchkick_index.exists?
|
18
18
|
assert different_index.exists?
|
@@ -23,7 +23,7 @@ class IndexTest < Minitest::Test
|
|
23
23
|
old_index = Searchkick::Index.new("products_test_20130801000000")
|
24
24
|
old_index.create
|
25
25
|
|
26
|
-
Product.clean_indices
|
26
|
+
Product.searchkick_index.clean_indices
|
27
27
|
|
28
28
|
assert !old_index.exists?
|
29
29
|
end
|
@@ -35,19 +35,13 @@ class IndexTest < Minitest::Test
|
|
35
35
|
|
36
36
|
def test_mapping
|
37
37
|
store_names ["Dollar Tree"], Store
|
38
|
-
assert_equal [], Store.search(query: {match: {name: "dollar"}}).map(&:name)
|
39
|
-
assert_equal ["Dollar Tree"], Store.search(query: {match: {name: "Dollar Tree"}}).map(&:name)
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_json
|
43
|
-
store_names ["Dollar Tree"], Store
|
44
|
-
assert_equal [], Store.search(query: {match: {name: "dollar"}}).map(&:name)
|
45
|
-
assert_equal ["Dollar Tree"], Store.search(json: {query: {match: {name: "Dollar Tree"}}}, load: false).map(&:name)
|
38
|
+
assert_equal [], Store.search(body: {query: {match: {name: "dollar"}}}).map(&:name)
|
39
|
+
assert_equal ["Dollar Tree"], Store.search(body: {query: {match: {name: "Dollar Tree"}}}).map(&:name)
|
46
40
|
end
|
47
41
|
|
48
42
|
def test_body
|
49
43
|
store_names ["Dollar Tree"], Store
|
50
|
-
assert_equal [], Store.search(query: {match: {name: "dollar"}}).map(&:name)
|
44
|
+
assert_equal [], Store.search(body: {query: {match: {name: "dollar"}}}).map(&:name)
|
51
45
|
assert_equal ["Dollar Tree"], Store.search(body: {query: {match: {name: "Dollar Tree"}}}, load: false).map(&:name)
|
52
46
|
end
|
53
47
|
|
@@ -61,7 +55,7 @@ class IndexTest < Minitest::Test
|
|
61
55
|
end
|
62
56
|
|
63
57
|
def test_tokens
|
64
|
-
assert_equal ["dollar", "dollartre", "tree"], Product.searchkick_index.tokens("Dollar Tree")
|
58
|
+
assert_equal ["dollar", "dollartre", "tree"], Product.searchkick_index.tokens("Dollar Tree", analyzer: "searchkick_index")
|
65
59
|
end
|
66
60
|
|
67
61
|
def test_tokens_analyzer
|
data/test/inheritance_test.rb
CHANGED
@@ -40,13 +40,13 @@ class InheritanceTest < Minitest::Test
|
|
40
40
|
def test_child_autocomplete
|
41
41
|
store_names ["Max"], Cat
|
42
42
|
store_names ["Mark"], Dog
|
43
|
-
assert_equal ["Max"], Cat.search("ma", fields: [:name],
|
43
|
+
assert_equal ["Max"], Cat.search("ma", fields: [:name], match: :text_start).map(&:name)
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_parent_autocomplete
|
47
47
|
store_names ["Max"], Cat
|
48
48
|
store_names ["Bear"], Dog
|
49
|
-
assert_equal ["Bear"], Animal.search("bea", fields: [:name],
|
49
|
+
assert_equal ["Bear"], Animal.search("bea", fields: [:name], match: :text_start).map(&:name).sort
|
50
50
|
end
|
51
51
|
|
52
52
|
# def test_child_suggest
|
data/test/match_test.rb
CHANGED
@@ -112,14 +112,12 @@ class MatchTest < Minitest::Test
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def test_misspelling_zucchini_transposition
|
115
|
-
skip if elasticsearch_below14?
|
116
115
|
store_names ["zucchini"]
|
117
116
|
assert_search "zuccihni", ["zucchini"]
|
118
117
|
assert_search "zuccihni", [], misspellings: {transpositions: false}
|
119
118
|
end
|
120
119
|
|
121
120
|
def test_misspelling_lasagna
|
122
|
-
skip if elasticsearch_below14?
|
123
121
|
store_names ["lasagna"]
|
124
122
|
assert_search "lasanga", ["lasagna"], misspellings: {transpositions: true}
|
125
123
|
assert_search "lasgana", ["lasagna"], misspellings: {transpositions: true}
|
@@ -128,7 +126,6 @@ class MatchTest < Minitest::Test
|
|
128
126
|
end
|
129
127
|
|
130
128
|
def test_misspelling_lasagna_pasta
|
131
|
-
skip if elasticsearch_below14?
|
132
129
|
store_names ["lasagna pasta"]
|
133
130
|
assert_search "lasanga", ["lasagna pasta"], misspellings: {transpositions: true}
|
134
131
|
assert_search "lasanga pasta", ["lasagna pasta"], misspellings: {transpositions: true}
|
data/test/query_test.rb
CHANGED
@@ -12,9 +12,8 @@ class QueryTest < Minitest::Test
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_with_effective_min_score
|
15
|
-
min_score = elasticsearch_below50? ? 0.1 : 1
|
16
15
|
store_names ["Milk", "Milk2"]
|
17
|
-
assert_search "milk", ["Milk"], body_options: {min_score:
|
16
|
+
assert_search "milk", ["Milk"], body_options: {min_score: 1}
|
18
17
|
end
|
19
18
|
|
20
19
|
def test_with_uneffective_min_score
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
|
3
|
+
class ReindexTest < Minitest::Test
|
4
|
+
def setup
|
5
|
+
skip if nobrainer?
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_scoped
|
10
|
+
store_names ["Product A"]
|
11
|
+
Searchkick.callbacks(false) do
|
12
|
+
store_names ["Product B", "Product C"]
|
13
|
+
end
|
14
|
+
Product.where(name: "Product B").reindex(refresh: true)
|
15
|
+
assert_search "product", ["Product A", "Product B"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_associations
|
19
|
+
store_names ["Product A"]
|
20
|
+
store = Store.create!(name: "Test")
|
21
|
+
Product.create!(name: "Product B", store_id: store.id)
|
22
|
+
store.products.reindex(refresh: true)
|
23
|
+
assert_search "product", ["Product A", "Product B"]
|
24
|
+
end
|
25
|
+
end
|
data/test/sql_test.rb
CHANGED
@@ -1,12 +1,6 @@
|
|
1
1
|
require_relative "test_helper"
|
2
2
|
|
3
3
|
class SqlTest < Minitest::Test
|
4
|
-
def test_partial
|
5
|
-
store_names ["Honey"]
|
6
|
-
assert_search "fresh honey", []
|
7
|
-
assert_search "fresh honey", ["Honey"], partial: true
|
8
|
-
end
|
9
|
-
|
10
4
|
def test_operator
|
11
5
|
store_names ["Honey"]
|
12
6
|
assert_search "fresh honey", []
|
@@ -90,32 +84,28 @@ class SqlTest < Minitest::Test
|
|
90
84
|
# select
|
91
85
|
|
92
86
|
def test_select
|
93
|
-
skip unless elasticsearch_below50?
|
94
87
|
store [{name: "Product A", store_id: 1}]
|
95
88
|
result = Product.search("product", load: false, select: [:name, :store_id]).first
|
96
89
|
assert_equal %w(id name store_id), result.keys.reject { |k| k.start_with?("_") }.sort
|
97
|
-
assert_equal
|
98
|
-
assert_equal
|
90
|
+
assert_equal "Product A", result.name
|
91
|
+
assert_equal 1, result.store_id
|
99
92
|
end
|
100
93
|
|
101
94
|
def test_select_array
|
102
|
-
skip unless elasticsearch_below50?
|
103
95
|
store [{name: "Product A", user_ids: [1, 2]}]
|
104
96
|
result = Product.search("product", load: false, select: [:user_ids]).first
|
105
97
|
assert_equal [1, 2], result.user_ids
|
106
98
|
end
|
107
99
|
|
108
100
|
def test_select_single_field
|
109
|
-
skip unless elasticsearch_below50?
|
110
101
|
store [{name: "Product A", store_id: 1}]
|
111
102
|
result = Product.search("product", load: false, select: :name).first
|
112
103
|
assert_equal %w(id name), result.keys.reject { |k| k.start_with?("_") }.sort
|
113
|
-
assert_equal
|
104
|
+
assert_equal "Product A", result.name
|
114
105
|
assert_nil result.store_id
|
115
106
|
end
|
116
107
|
|
117
108
|
def test_select_all
|
118
|
-
skip unless elasticsearch_below50?
|
119
109
|
store [{name: "Product A", user_ids: [1, 2]}]
|
120
110
|
hit = Product.search("product", select: true).hits.first
|
121
111
|
assert_equal hit["_source"]["name"], "Product A"
|
@@ -123,102 +113,64 @@ class SqlTest < Minitest::Test
|
|
123
113
|
end
|
124
114
|
|
125
115
|
def test_select_none
|
126
|
-
skip unless elasticsearch_below50?
|
127
116
|
store [{name: "Product A", user_ids: [1, 2]}]
|
128
117
|
hit = Product.search("product", select: []).hits.first
|
129
118
|
assert_nil hit["_source"]
|
130
|
-
|
131
|
-
|
132
|
-
# select_v2
|
133
|
-
|
134
|
-
def test_select_v2
|
135
|
-
store [{name: "Product A", store_id: 1}]
|
136
|
-
result = Product.search("product", load: false, select_v2: [:name, :store_id]).first
|
137
|
-
assert_equal %w(id name store_id), result.keys.reject { |k| k.start_with?("_") }.sort
|
138
|
-
assert_equal "Product A", result.name
|
139
|
-
assert_equal 1, result.store_id
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_select_v2_array
|
143
|
-
store [{name: "Product A", user_ids: [1, 2]}]
|
144
|
-
result = Product.search("product", load: false, select_v2: [:user_ids]).first
|
145
|
-
assert_equal [1, 2], result.user_ids
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_select_v2_single_field
|
149
|
-
store [{name: "Product A", store_id: 1}]
|
150
|
-
result = Product.search("product", load: false, select_v2: :name).first
|
151
|
-
assert_equal %w(id name), result.keys.reject { |k| k.start_with?("_") }.sort
|
152
|
-
assert_equal "Product A", result.name
|
153
|
-
assert_nil result.store_id
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_select_v2_all
|
157
|
-
store [{name: "Product A", user_ids: [1, 2]}]
|
158
|
-
hit = Product.search("product", select_v2: true).hits.first
|
159
|
-
assert_equal hit["_source"]["name"], "Product A"
|
160
|
-
assert_equal hit["_source"]["user_ids"], [1, 2]
|
161
|
-
end
|
162
|
-
|
163
|
-
def test_select_v2_none
|
164
|
-
store [{name: "Product A", user_ids: [1, 2]}]
|
165
|
-
hit = Product.search("product", select_v2: []).hits.first
|
166
|
-
assert_nil hit["_source"]
|
167
|
-
hit = Product.search("product", select_v2: false).hits.first
|
119
|
+
hit = Product.search("product", select: false).hits.first
|
168
120
|
assert_nil hit["_source"]
|
169
121
|
end
|
170
122
|
|
171
|
-
def
|
123
|
+
def test_select_include
|
172
124
|
skip unless elasticsearch_below50?
|
173
125
|
store [{name: "Product A", user_ids: [1, 2]}]
|
174
|
-
result = Product.search("product", load: false,
|
126
|
+
result = Product.search("product", load: false, select: {include: [:name]}).first
|
175
127
|
assert_equal %w(id name), result.keys.reject { |k| k.start_with?("_") }.sort
|
176
128
|
assert_equal "Product A", result.name
|
177
129
|
assert_nil result.store_id
|
178
130
|
end
|
179
131
|
|
180
|
-
def
|
132
|
+
def test_select_exclude
|
181
133
|
skip unless elasticsearch_below50?
|
182
134
|
store [{name: "Product A", user_ids: [1, 2], store_id: 1}]
|
183
|
-
result = Product.search("product", load: false,
|
135
|
+
result = Product.search("product", load: false, select: {exclude: [:name]}).first
|
184
136
|
assert_nil result.name
|
185
137
|
assert_equal [1, 2], result.user_ids
|
186
138
|
assert_equal 1, result.store_id
|
187
139
|
end
|
188
140
|
|
189
|
-
def
|
141
|
+
def test_select_include_and_exclude
|
190
142
|
skip unless elasticsearch_below50?
|
191
143
|
# let's take this to the next level
|
192
144
|
store [{name: "Product A", user_ids: [1, 2], store_id: 1}]
|
193
|
-
result = Product.search("product", load: false,
|
145
|
+
result = Product.search("product", load: false, select: {include: [:store_id], exclude: [:name]}).first
|
194
146
|
assert_equal 1, result.store_id
|
195
147
|
assert_nil result.name
|
196
148
|
assert_nil result.user_ids
|
197
149
|
end
|
198
150
|
|
199
|
-
def
|
151
|
+
def test_select_includes
|
200
152
|
skip if elasticsearch_below50?
|
201
153
|
store [{name: "Product A", user_ids: [1, 2]}]
|
202
|
-
result = Product.search("product", load: false,
|
154
|
+
result = Product.search("product", load: false, select: {includes: [:name]}).first
|
203
155
|
assert_equal %w(id name), result.keys.reject { |k| k.start_with?("_") }.sort
|
204
156
|
assert_equal "Product A", result.name
|
205
157
|
assert_nil result.store_id
|
206
158
|
end
|
207
159
|
|
208
|
-
def
|
160
|
+
def test_select_excludes
|
209
161
|
skip if elasticsearch_below50?
|
210
162
|
store [{name: "Product A", user_ids: [1, 2], store_id: 1}]
|
211
|
-
result = Product.search("product", load: false,
|
163
|
+
result = Product.search("product", load: false, select: {excludes: [:name]}).first
|
212
164
|
assert_nil result.name
|
213
165
|
assert_equal [1, 2], result.user_ids
|
214
166
|
assert_equal 1, result.store_id
|
215
167
|
end
|
216
168
|
|
217
|
-
def
|
169
|
+
def test_select_include_and_excludes
|
218
170
|
skip if elasticsearch_below50?
|
219
171
|
# let's take this to the next level
|
220
172
|
store [{name: "Product A", user_ids: [1, 2], store_id: 1}]
|
221
|
-
result = Product.search("product", load: false,
|
173
|
+
result = Product.search("product", load: false, select: {includes: [:store_id], excludes: [:name]}).first
|
222
174
|
assert_equal 1, result.store_id
|
223
175
|
assert_nil result.name
|
224
176
|
assert_nil result.user_ids
|
data/test/test_helper.rb
CHANGED
@@ -29,47 +29,16 @@ def elasticsearch_below22?
|
|
29
29
|
Searchkick.server_below?("2.2.0")
|
30
30
|
end
|
31
31
|
|
32
|
-
def elasticsearch_below20?
|
33
|
-
Searchkick.server_below?("2.0.0")
|
34
|
-
end
|
35
|
-
|
36
|
-
def elasticsearch_below14?
|
37
|
-
Searchkick.server_below?("1.4.0")
|
38
|
-
end
|
39
|
-
|
40
|
-
def mongoid2?
|
41
|
-
defined?(Mongoid) && Mongoid::VERSION.starts_with?("2.")
|
42
|
-
end
|
43
|
-
|
44
32
|
def nobrainer?
|
45
33
|
defined?(NoBrainer)
|
46
34
|
end
|
47
35
|
|
48
|
-
def activerecord_below41?
|
49
|
-
defined?(ActiveRecord) && Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("4.1.0")
|
50
|
-
end
|
51
|
-
|
52
36
|
if defined?(Mongoid)
|
53
37
|
Mongoid.logger.level = Logger::INFO
|
54
38
|
Mongo::Logger.logger.level = Logger::INFO if defined?(Mongo::Logger)
|
55
39
|
|
56
|
-
if mongoid2?
|
57
|
-
# enable comparison of BSON::ObjectIds
|
58
|
-
module BSON
|
59
|
-
class ObjectId
|
60
|
-
def <=>(other)
|
61
|
-
data <=> other.data
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
40
|
Mongoid.configure do |config|
|
68
|
-
|
69
|
-
config.master = Mongo::Connection.new.db("searchkick_test")
|
70
|
-
else
|
71
|
-
config.connect_to "searchkick_test"
|
72
|
-
end
|
41
|
+
config.connect_to "searchkick_test"
|
73
42
|
end
|
74
43
|
|
75
44
|
class Product
|
@@ -303,10 +272,8 @@ class Product
|
|
303
272
|
"lightbulb => led,lightbulb",
|
304
273
|
"lightbulb => halogenlamp"
|
305
274
|
],
|
306
|
-
autocomplete: [:name],
|
307
275
|
suggest: [:name, :color],
|
308
276
|
conversions: [:conversions],
|
309
|
-
personalize: :user_ids,
|
310
277
|
locations: [:location, :multiple_locations],
|
311
278
|
text_start: [:name],
|
312
279
|
text_middle: [:name],
|
@@ -316,10 +283,8 @@ class Product
|
|
316
283
|
word_end: [:name],
|
317
284
|
highlight: [:name],
|
318
285
|
searchable: [:name, :color],
|
319
|
-
default_fields: [:name, :color],
|
320
286
|
filterable: [:name, :color, :description],
|
321
|
-
|
322
|
-
# only_analyzed: [:alt_description],
|
287
|
+
similarity: "BM25",
|
323
288
|
match: ENV["MATCH"] ? ENV["MATCH"].to_sym : nil
|
324
289
|
|
325
290
|
attr_accessor :conversions, :user_ids, :aisle, :details
|
@@ -401,7 +366,7 @@ end
|
|
401
366
|
|
402
367
|
class Animal
|
403
368
|
searchkick \
|
404
|
-
|
369
|
+
text_start: [:name],
|
405
370
|
suggest: [:name],
|
406
371
|
index_name: -> { "#{name.tableize}-#{Date.today.year}" }
|
407
372
|
# wordnet: true
|