searchkick 5.0.4 → 5.0.5
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/CHANGELOG.md +7 -0
- data/README.md +11 -5
- data/lib/searchkick/relation.rb +24 -2
- data/lib/searchkick/relation_indexer.rb +2 -2
- data/lib/searchkick/results.rb +2 -0
- data/lib/searchkick/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a93f95464f2b83d27f621d925326ea3b7728b2d71fff9831e20e07658ff0466
|
4
|
+
data.tar.gz: acf15b38474dea853f3e3574ea5fac21d4129920b6365e2c92ca58cfaf518cc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51f9d3b6c110a7ec24988518b7e154fef368c2d027c00337e54096c3214871d29da9bdc9e549d4b9967742636bb8ae60d5a288ca066ff992691692a017b9bdda
|
7
|
+
data.tar.gz: 811825c1043231828c2d04a3a2081e453440fd470563680c8e470fea00569ffe57109bca64e07978ba8944d53a03f95c9fd4768872d6bf2ae6c4e87ede961e7a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 5.0.5 (2022-10-09)
|
2
|
+
|
3
|
+
- Added `model` method to `Searchkick::Relation`
|
4
|
+
- Fixed deprecation warning with `redis` gem
|
5
|
+
- Fixed `respond_to?` method on relation loading relation
|
6
|
+
- Fixed `Relation loaded` error for non-mutating methods on relation
|
7
|
+
|
1
8
|
## 5.0.4 (2022-06-16)
|
2
9
|
|
3
10
|
- Added `max_result_window` option
|
data/README.md
CHANGED
@@ -292,12 +292,18 @@ Option | Matches | Example
|
|
292
292
|
|
293
293
|
The default is `:word`. The most matches will happen with `:word_middle`.
|
294
294
|
|
295
|
+
To specify different matching for different fields, use:
|
296
|
+
|
297
|
+
```ruby
|
298
|
+
Product.search(query, fields: [{name: :word_start}, {brand: :word_middle}])
|
299
|
+
```
|
300
|
+
|
295
301
|
### Exact Matches
|
296
302
|
|
297
303
|
To match a field exactly (case-sensitive), use:
|
298
304
|
|
299
305
|
```ruby
|
300
|
-
Product.search(query, fields: [{
|
306
|
+
Product.search(query, fields: [{name: :exact}])
|
301
307
|
```
|
302
308
|
|
303
309
|
### Phrase Matches
|
@@ -323,11 +329,11 @@ end
|
|
323
329
|
See the [list of languages](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-stemmer-tokenfilter.html#analysis-stemmer-tokenfilter-configure-parms). A few languages require plugins:
|
324
330
|
|
325
331
|
- `chinese` - [analysis-ik plugin](https://github.com/medcl/elasticsearch-analysis-ik)
|
326
|
-
- `chinese2` - [analysis-smartcn plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/
|
327
|
-
- `japanese` - [analysis-kuromoji plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/
|
332
|
+
- `chinese2` - [analysis-smartcn plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-smartcn.html)
|
333
|
+
- `japanese` - [analysis-kuromoji plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-kuromoji.html)
|
328
334
|
- `korean` - [analysis-openkoreantext plugin](https://github.com/open-korean-text/elasticsearch-analysis-openkoreantext)
|
329
|
-
- `korean2` - [analysis-nori plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/
|
330
|
-
- `polish` - [analysis-stempel plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/
|
335
|
+
- `korean2` - [analysis-nori plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-nori.html)
|
336
|
+
- `polish` - [analysis-stempel plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-stempel.html)
|
331
337
|
- `ukrainian` - [analysis-ukrainian plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/7.4/analysis-ukrainian.html)
|
332
338
|
- `vietnamese` - [analysis-vietnamese plugin](https://github.com/duydo/elasticsearch-analysis-vietnamese)
|
333
339
|
|
data/lib/searchkick/relation.rb
CHANGED
@@ -8,6 +8,9 @@ module Searchkick
|
|
8
8
|
delegate :body, :params, to: :query
|
9
9
|
delegate_missing_to :private_execute
|
10
10
|
|
11
|
+
attr_reader :model
|
12
|
+
alias_method :klass, :model
|
13
|
+
|
11
14
|
def initialize(model, term = "*", **options)
|
12
15
|
@model = model
|
13
16
|
@term = term
|
@@ -26,8 +29,7 @@ module Searchkick
|
|
26
29
|
|
27
30
|
def execute
|
28
31
|
Searchkick.warn("The execute method is no longer needed")
|
29
|
-
|
30
|
-
self
|
32
|
+
load
|
31
33
|
end
|
32
34
|
|
33
35
|
# experimental
|
@@ -195,10 +197,25 @@ module Searchkick
|
|
195
197
|
Relation.new(@model, @term, **@options.except(*keys))
|
196
198
|
end
|
197
199
|
|
200
|
+
# experimental
|
201
|
+
def load
|
202
|
+
private_execute
|
203
|
+
self
|
204
|
+
end
|
205
|
+
|
198
206
|
def loaded?
|
199
207
|
!@execute.nil?
|
200
208
|
end
|
201
209
|
|
210
|
+
def respond_to_missing?(method_name, include_all)
|
211
|
+
Results.new(nil, nil, nil).respond_to?(method_name, include_all) || super
|
212
|
+
end
|
213
|
+
|
214
|
+
# TODO uncomment in 6.0
|
215
|
+
# def to_yaml
|
216
|
+
# private_execute.to_a.to_yaml
|
217
|
+
# end
|
218
|
+
|
202
219
|
private
|
203
220
|
|
204
221
|
def private_execute
|
@@ -221,5 +238,10 @@ module Searchkick
|
|
221
238
|
def ensure_permitted(obj)
|
222
239
|
obj.to_h
|
223
240
|
end
|
241
|
+
|
242
|
+
def initialize_copy(other)
|
243
|
+
super
|
244
|
+
@execute = nil
|
245
|
+
end
|
224
246
|
end
|
225
247
|
end
|
@@ -46,7 +46,7 @@ module Searchkick
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def batch_completed(batch_id)
|
49
|
-
Searchkick.with_redis { |r| r.srem(batches_key, batch_id) }
|
49
|
+
Searchkick.with_redis { |r| r.srem(batches_key, [batch_id]) }
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
@@ -134,7 +134,7 @@ module Searchkick
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def batch_job(class_name, batch_id, record_ids)
|
137
|
-
Searchkick.with_redis { |r| r.sadd(batches_key, batch_id) }
|
137
|
+
Searchkick.with_redis { |r| r.sadd(batches_key, [batch_id]) }
|
138
138
|
Searchkick::BulkReindexJob.perform_later(
|
139
139
|
class_name: class_name,
|
140
140
|
index_name: index.name,
|
data/lib/searchkick/results.rb
CHANGED
@@ -3,6 +3,7 @@ module Searchkick
|
|
3
3
|
include Enumerable
|
4
4
|
extend Forwardable
|
5
5
|
|
6
|
+
# TODO remove klass and options in 6.0
|
6
7
|
attr_reader :klass, :response, :options
|
7
8
|
|
8
9
|
def_delegators :results, :each, :any?, :empty?, :size, :length, :slice, :[], :to_ary
|
@@ -13,6 +14,7 @@ module Searchkick
|
|
13
14
|
@options = options
|
14
15
|
end
|
15
16
|
|
17
|
+
# TODO make private in 6.0
|
16
18
|
def results
|
17
19
|
@results ||= with_hit.map(&:first)
|
18
20
|
end
|
data/lib/searchkick/version.rb
CHANGED
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: 5.0.
|
4
|
+
version: 5.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|