searchkick 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +6 -4
- data/lib/searchkick/index_options.rb +24 -0
- data/lib/searchkick/multi_search.rb +6 -6
- data/lib/searchkick/query.rb +1 -1
- data/lib/searchkick/record_data.rb +0 -5
- data/lib/searchkick/record_indexer.rb +5 -1
- data/lib/searchkick/version.rb +1 -1
- data/test/language_test.rb +19 -0
- data/test/multi_search_test.rb +1 -1
- data/test/partial_reindex_test.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 755a0e68ea42b18bb5d3ab111bec8d7f95a0bce2
|
4
|
+
data.tar.gz: 5ed049addff00159cfe9a4c7db03ea81cb9383ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cab627210801732d119796bce578d42289d808199a1f3a3510343ded21c4513ecad2f2e7259a435fc4c31db13e89995bf659195fa783c5d5747c0c0e554ee76f
|
7
|
+
data.tar.gz: 4b06af47509a66eafc9f8bc6080e28a72fbd03998c4b7307b4e26cb950a5d52417ace6261a9b974dcf809fb535af75c5789a2e1ae96c45c66dd630dd9e0b76fc
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
+
## 3.0.2
|
2
|
+
|
3
|
+
- Added support for Korean and Vietnamese
|
4
|
+
- Fixed `Unsupported argument type: Symbol` for async partial reindex
|
5
|
+
- Fixed infinite recursion with multi search and misspellings below
|
6
|
+
- Do not raise an error when `id` is indexed
|
7
|
+
|
1
8
|
## 3.0.1
|
2
9
|
|
3
10
|
- Added `scope` option for partial reindex
|
4
|
-
- Added support for Japanese, Polish, and
|
11
|
+
- Added support for Japanese, Polish, and Ukrainian
|
5
12
|
|
6
13
|
## 3.0.0
|
7
14
|
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Plus:
|
|
22
22
|
- supports many languages
|
23
23
|
- works with ActiveRecord, Mongoid, and NoBrainer
|
24
24
|
|
25
|
-
:speech_balloon: Get [handcrafted updates](
|
25
|
+
:speech_balloon: Get [handcrafted updates](https://chartkick.us7.list-manage.com/subscribe?u=952c861f99eb43084e0a49f98&id=6ea6541e8e&group[0][4]=true) for new features
|
26
26
|
|
27
27
|
:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
|
28
28
|
|
@@ -302,10 +302,12 @@ end
|
|
302
302
|
|
303
303
|
A few languages require plugins:
|
304
304
|
|
305
|
-
- `chinese` - [
|
305
|
+
- `chinese` - [analysis-ik plugin](https://github.com/medcl/elasticsearch-analysis-ik)
|
306
306
|
- `japanese` - [analysis-kuromoji plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-kuromoji.html)
|
307
|
+
- `korean` - [analysis-openkoreantext plugin](https://github.com/open-korean-text/elasticsearch-analysis-openkoreantext)
|
307
308
|
- `polish` - [analysis-stempel plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-stempel.html)
|
308
309
|
- `ukrainian` - [analysis-ukrainian plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-ukrainian.html)
|
310
|
+
- `vietnamese` - [analysis-vietnamese plugin](https://github.com/duydo/elasticsearch-analysis-vietnamese)
|
309
311
|
|
310
312
|
### Synonyms
|
311
313
|
|
@@ -654,7 +656,7 @@ Reindex and search with:
|
|
654
656
|
Movie.search "jurassic pa", fields: [:title], match: :word_start
|
655
657
|
```
|
656
658
|
|
657
|
-
Typically, you want to use a JavaScript library like [typeahead.js](
|
659
|
+
Typically, you want to use a JavaScript library like [typeahead.js](https://twitter.github.io/typeahead.js/) or [jQuery UI](https://jqueryui.com/autocomplete/).
|
658
660
|
|
659
661
|
#### Here’s how to make it work with Rails
|
660
662
|
|
@@ -854,7 +856,7 @@ class Restaurant < ApplicationRecord
|
|
854
856
|
searchkick locations: [:location]
|
855
857
|
|
856
858
|
def search_data
|
857
|
-
attributes.merge
|
859
|
+
attributes.merge(location: {lat: latitude, lon: longitude})
|
858
860
|
end
|
859
861
|
end
|
860
862
|
```
|
@@ -169,6 +169,30 @@ module Searchkick
|
|
169
169
|
type: "kuromoji"
|
170
170
|
}
|
171
171
|
)
|
172
|
+
when "korean"
|
173
|
+
settings[:analysis][:analyzer].merge!(
|
174
|
+
default_analyzer => {
|
175
|
+
type: "openkoreantext-analyzer"
|
176
|
+
},
|
177
|
+
searchkick_search: {
|
178
|
+
type: "openkoreantext-analyzer"
|
179
|
+
},
|
180
|
+
searchkick_search2: {
|
181
|
+
type: "openkoreantext-analyzer"
|
182
|
+
}
|
183
|
+
)
|
184
|
+
when "vietnamese"
|
185
|
+
settings[:analysis][:analyzer].merge!(
|
186
|
+
default_analyzer => {
|
187
|
+
type: "vi_analyzer"
|
188
|
+
},
|
189
|
+
searchkick_search: {
|
190
|
+
type: "vi_analyzer"
|
191
|
+
},
|
192
|
+
searchkick_search2: {
|
193
|
+
type: "vi_analyzer"
|
194
|
+
}
|
195
|
+
)
|
172
196
|
when "polish", "ukrainian", "smartcn"
|
173
197
|
settings[:analysis][:analyzer].merge!(
|
174
198
|
default_analyzer => {
|
@@ -14,12 +14,12 @@ module Searchkick
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
def perform_search(
|
18
|
-
responses = client.msearch(body:
|
17
|
+
def perform_search(search_queries, perform_retry: true)
|
18
|
+
responses = client.msearch(body: search_queries.flat_map { |q| [q.params.except(:body), q.body] })["responses"]
|
19
19
|
|
20
20
|
retry_queries = []
|
21
|
-
|
22
|
-
if query.retry_misspellings?(responses[i])
|
21
|
+
search_queries.each_with_index do |query, i|
|
22
|
+
if perform_retry && query.retry_misspellings?(responses[i])
|
23
23
|
query.send(:prepare) # okay, since we don't want to expose this method outside Searchkick
|
24
24
|
retry_queries << query
|
25
25
|
else
|
@@ -28,10 +28,10 @@ module Searchkick
|
|
28
28
|
end
|
29
29
|
|
30
30
|
if retry_queries.any?
|
31
|
-
perform_search(retry_queries)
|
31
|
+
perform_search(retry_queries, perform_retry: false)
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
search_queries
|
35
35
|
end
|
36
36
|
|
37
37
|
def client
|
data/lib/searchkick/query.rb
CHANGED
@@ -317,7 +317,7 @@ module Searchkick
|
|
317
317
|
qs << shared_options.merge(analyzer: "searchkick_search")
|
318
318
|
|
319
319
|
# searchkick_search and searchkick_search2 are the same for ukrainian
|
320
|
-
unless %w(japanese polish ukrainian).include?(searchkick_options[:language])
|
320
|
+
unless %w(japanese korean polish ukrainian vietnamese).include?(searchkick_options[:language])
|
321
321
|
qs << shared_options.merge(analyzer: "searchkick_search2")
|
322
322
|
end
|
323
323
|
exclude_analyzer = "searchkick_search2"
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Searchkick
|
2
2
|
class RecordData
|
3
|
-
EXCLUDED_ATTRIBUTES = ["id", :id]
|
4
3
|
TYPE_KEYS = ["type", :type]
|
5
4
|
|
6
5
|
attr_reader :index, :record
|
@@ -50,11 +49,7 @@ module Searchkick
|
|
50
49
|
def search_data(method_name = nil)
|
51
50
|
partial_reindex = !method_name.nil?
|
52
51
|
|
53
|
-
# remove _id since search_id is used instead
|
54
52
|
source = record.send(method_name || :search_data)
|
55
|
-
EXCLUDED_ATTRIBUTES.each do |attr|
|
56
|
-
raise Searchkick::Error, "Cannot index a field with name: #{attr}" if source[attr]
|
57
|
-
end
|
58
53
|
|
59
54
|
# conversions
|
60
55
|
index.conversions_fields.each do |conversions_field|
|
@@ -26,7 +26,11 @@ module Searchkick
|
|
26
26
|
raise Searchkick::Error, "Active Job not found"
|
27
27
|
end
|
28
28
|
|
29
|
-
Searchkick::ReindexV2Job.perform_later(
|
29
|
+
Searchkick::ReindexV2Job.perform_later(
|
30
|
+
record.class.name,
|
31
|
+
record.id.to_s,
|
32
|
+
method_name ? method_name.to_s : nil
|
33
|
+
)
|
30
34
|
else # bulk, true
|
31
35
|
reindex_record(method_name)
|
32
36
|
|
data/lib/searchkick/version.rb
CHANGED
data/test/language_test.rb
CHANGED
@@ -38,6 +38,16 @@ class LanguageTest < Minitest::Test
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def test_korean
|
42
|
+
# requires https://github.com/open-korean-text/elasticsearch-analysis-openkoreantext
|
43
|
+
with_options(Song, language: "korean") do
|
44
|
+
store_names ["한국어를 처리하는 예시입니닼ㅋㅋ"], Song
|
45
|
+
assert_language_search "처리", ["한국어를 처리하는 예시입니닼ㅋㅋ"]
|
46
|
+
assert_language_search "한국어", ["한국어를 처리하는 예시입니닼ㅋㅋ"]
|
47
|
+
assert_language_search "를", []
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
41
51
|
def test_polish
|
42
52
|
# requires https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-stempel.html
|
43
53
|
with_options(Song, language: "polish") do
|
@@ -54,6 +64,15 @@ class LanguageTest < Minitest::Test
|
|
54
64
|
end
|
55
65
|
end
|
56
66
|
|
67
|
+
def test_vietnamese
|
68
|
+
# requires https://github.com/duydo/elasticsearch-analysis-vietnamese
|
69
|
+
with_options(Song, language: "vietnamese") do
|
70
|
+
store_names ["công nghệ thông tin Việt Nam"], Song
|
71
|
+
assert_language_search "công nghệ thông tin", ["công nghệ thông tin Việt Nam"]
|
72
|
+
assert_language_search "công", []
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
57
76
|
def assert_language_search(term, expected)
|
58
77
|
assert_search term, expected, {misspellings: false}, Song
|
59
78
|
end
|
data/test/multi_search_test.rb
CHANGED
@@ -22,7 +22,7 @@ class MultiSearchTest < Minitest::Test
|
|
22
22
|
|
23
23
|
def test_misspellings_below_unmet
|
24
24
|
store_names ["abc", "abd", "aee"]
|
25
|
-
products = Product.search("abc", misspellings: {below:
|
25
|
+
products = Product.search("abc", misspellings: {below: 5}, execute: false)
|
26
26
|
Searchkick.multi_search([products])
|
27
27
|
assert_equal ["abc", "abd"], products.map(&:name)
|
28
28
|
end
|
@@ -55,4 +55,11 @@ class PartialReindexTest < Minitest::Test
|
|
55
55
|
assert_search "bye", ["Bye"], fields: [:name], load: false
|
56
56
|
assert_search "blue", ["Bye"], fields: [:color], load: false
|
57
57
|
end
|
58
|
+
|
59
|
+
def test_instance_method_async
|
60
|
+
skip unless defined?(ActiveJob)
|
61
|
+
|
62
|
+
product = Product.create!(name: "Hi")
|
63
|
+
product.reindex(:search_data, mode: :async)
|
64
|
+
end
|
58
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|