searchkick 5.2.0 → 5.2.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 +9 -0
- data/README.md +4 -0
- data/lib/searchkick/index.rb +2 -1
- data/lib/searchkick/log_subscriber.rb +3 -3
- data/lib/searchkick/reindex_queue.rb +11 -6
- data/lib/searchkick/relation_indexer.rb +3 -3
- data/lib/searchkick/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3ada9c260b4ad16858d70480fafdc92d6bcbbeea240a628d832e5aaba4fea10
|
4
|
+
data.tar.gz: b9e48dc70ddfd83b10eeb1c02d572b6aaba66075c494c94fb8dd8450f7e39e7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9509e82eb6257fd25334e0527bb3bd890e5a40edc6710354700ebb826048888b1549756b3b34089de434f38517a53b648ae896ad1478e688a93a886a70d7675
|
7
|
+
data.tar.gz: 9b79d9dfad68255deccf6af74586ce877026652091b37baeeb60ec56f3af6b4923525846a68b7d3d008ed3baa81b1f765b76d2b6f68e6d014bcfa5ac413b4ad0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 5.2.2 (2023-04-01)
|
2
|
+
|
3
|
+
- Fixed `total_docs` method
|
4
|
+
- Fixed deprecation warning with Active Support 7.1
|
5
|
+
|
6
|
+
## 5.2.1 (2023-02-21)
|
7
|
+
|
8
|
+
- Added support for `redis-client` gem
|
9
|
+
|
1
10
|
## 5.2.0 (2023-02-08)
|
2
11
|
|
3
12
|
- Added model name to warning about missing records
|
data/README.md
CHANGED
@@ -1837,6 +1837,10 @@ To query nested data, use dot notation.
|
|
1837
1837
|
Product.search("san", fields: ["store.city"], where: {"store.zip_code" => 12345})
|
1838
1838
|
```
|
1839
1839
|
|
1840
|
+
## Nearest Neighbors
|
1841
|
+
|
1842
|
+
You can use custom mapping and searching to index vectors and perform k-nearest neighbor search. See the examples for [Elasticsearch](examples/elasticsearch_knn.rb) and [OpenSearch](examples/opensearch_knn.rb).
|
1843
|
+
|
1840
1844
|
## Reference
|
1841
1845
|
|
1842
1846
|
Reindex one record
|
data/lib/searchkick/index.rb
CHANGED
@@ -31,7 +31,7 @@ module Searchkick
|
|
31
31
|
params << "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"
|
32
32
|
end
|
33
33
|
|
34
|
-
debug " #{color(name, YELLOW, true)} #{index}#{type ? "/#{type.join(',')}" : ''}/_search#{params.any? ? '?' + params.join('&') : nil} #{payload[:query][:body].to_json}"
|
34
|
+
debug " #{color(name, YELLOW, bold: true)} #{index}#{type ? "/#{type.join(',')}" : ''}/_search#{params.any? ? '?' + params.join('&') : nil} #{payload[:query][:body].to_json}"
|
35
35
|
end
|
36
36
|
|
37
37
|
def request(event)
|
@@ -41,7 +41,7 @@ module Searchkick
|
|
41
41
|
payload = event.payload
|
42
42
|
name = "#{payload[:name]} (#{event.duration.round(1)}ms)"
|
43
43
|
|
44
|
-
debug " #{color(name, YELLOW, true)} #{payload.except(:name).to_json}"
|
44
|
+
debug " #{color(name, YELLOW, bold: true)} #{payload.except(:name).to_json}"
|
45
45
|
end
|
46
46
|
|
47
47
|
def multi_search(event)
|
@@ -51,7 +51,7 @@ module Searchkick
|
|
51
51
|
payload = event.payload
|
52
52
|
name = "#{payload[:name]} (#{event.duration.round(1)}ms)"
|
53
53
|
|
54
|
-
debug " #{color(name, YELLOW, true)} _msearch #{payload[:body]}"
|
54
|
+
debug " #{color(name, YELLOW, bold: true)} _msearch #{payload[:body]}"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -10,7 +10,7 @@ module Searchkick
|
|
10
10
|
|
11
11
|
# supports single and multiple ids
|
12
12
|
def push(record_ids)
|
13
|
-
Searchkick.with_redis { |r| r.
|
13
|
+
Searchkick.with_redis { |r| r.call("LPUSH", redis_key, record_ids) }
|
14
14
|
end
|
15
15
|
|
16
16
|
def push_records(records)
|
@@ -34,11 +34,11 @@ module Searchkick
|
|
34
34
|
# TODO use reliable queuing
|
35
35
|
def reserve(limit: 1000)
|
36
36
|
if supports_rpop_with_count?
|
37
|
-
Searchkick.with_redis { |r| r.call("
|
37
|
+
Searchkick.with_redis { |r| r.call("RPOP", redis_key, limit) }.to_a
|
38
38
|
else
|
39
39
|
record_ids = []
|
40
40
|
Searchkick.with_redis do |r|
|
41
|
-
while record_ids.size < limit && (record_id = r.
|
41
|
+
while record_ids.size < limit && (record_id = r.call("RPOP", redis_key))
|
42
42
|
record_ids << record_id
|
43
43
|
end
|
44
44
|
end
|
@@ -47,11 +47,11 @@ module Searchkick
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def clear
|
50
|
-
Searchkick.with_redis { |r| r.
|
50
|
+
Searchkick.with_redis { |r| r.call("DEL", redis_key) }
|
51
51
|
end
|
52
52
|
|
53
53
|
def length
|
54
|
-
Searchkick.with_redis { |r| r.
|
54
|
+
Searchkick.with_redis { |r| r.call("LLEN", redis_key) }
|
55
55
|
end
|
56
56
|
|
57
57
|
private
|
@@ -65,7 +65,12 @@ module Searchkick
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def redis_version
|
68
|
-
@redis_version ||=
|
68
|
+
@redis_version ||=
|
69
|
+
Searchkick.with_redis do |r|
|
70
|
+
info = r.call("INFO")
|
71
|
+
matches = /redis_version:(\S+)/.match(info)
|
72
|
+
Gem::Version.new(matches[1])
|
73
|
+
end
|
69
74
|
end
|
70
75
|
|
71
76
|
def escape(value)
|
@@ -47,11 +47,11 @@ module Searchkick
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def batches_left
|
50
|
-
Searchkick.with_redis { |r| r.
|
50
|
+
Searchkick.with_redis { |r| r.call("SCARD", batches_key) }
|
51
51
|
end
|
52
52
|
|
53
53
|
def batch_completed(batch_id)
|
54
|
-
Searchkick.with_redis { |r| r.
|
54
|
+
Searchkick.with_redis { |r| r.call("SREM", batches_key, [batch_id]) }
|
55
55
|
end
|
56
56
|
|
57
57
|
private
|
@@ -139,7 +139,7 @@ module Searchkick
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def batch_job(class_name, batch_id, record_ids)
|
142
|
-
Searchkick.with_redis { |r| r.
|
142
|
+
Searchkick.with_redis { |r| r.call("SADD", batches_key, [batch_id]) }
|
143
143
|
Searchkick::BulkReindexJob.perform_later(
|
144
144
|
class_name: class_name,
|
145
145
|
index_name: index.name,
|
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.2.
|
4
|
+
version: 5.2.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: 2023-
|
11
|
+
date: 2023-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
rubygems_version: 3.4.
|
95
|
+
rubygems_version: 3.4.10
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Intelligent search made easy with Rails and Elasticsearch or OpenSearch
|