searchkick 5.2.0 → 5.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bea8e9ff3ed31f14751a19c74ecfa76f276d0e1e6d12803203bd023e0aba6926
4
- data.tar.gz: 060ab7e11f615f1b0b32494e38eb35135ee6d5b1df203bb7dadd04b9e9eb8886
3
+ metadata.gz: cd5ad80ede7109fee3886bc0e5c27b8f2e4a39ed9530ac3a0c4683d8281dcd7c
4
+ data.tar.gz: 41c8736fc385b97d14ee1f0aef72cd8fbefad6d171dae879066901af5481fef1
5
5
  SHA512:
6
- metadata.gz: 80e3c1e347ddd12750e1e9ebba5ef15c49915cbff4c1999733dc8663e750ad9aafc2a265865593572f5fec3ec9c6f0d9a0992a204154102f3829d75f0459cd6d
7
- data.tar.gz: a2d8dc9d74f1cc9a744a9bdcbb735e078a4f80114d441df26953e1b32e6a7f9ff5847c6619e540a468dabc933811f1e9bc47396bbaa34103942102eb253ddedb
6
+ metadata.gz: a8dd0e09fe48cc48e240d295fd350734bfe787e06611a5f3637e4b9d7e81afa327ea42fbe5912024c06bbe6de55ecbb41ecac57d98d6194bf7d94e34d89eb39c
7
+ data.tar.gz: ba98108eda0e4cb2d3884e3402246ad2c269a11438d6eb62ee2346b2cbfe6dd2c4e2865df5ed52bfef6faf3dbc031dc4ca3d6aefb0c5d7487b347b496bd3b29e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 5.2.1 (2023-02-21)
2
+
3
+ - Added support for `redis-client` gem
4
+
1
5
  ## 5.2.0 (2023-02-08)
2
6
 
3
7
  - 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
@@ -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.lpush(redis_key, record_ids) }
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("rpop", redis_key, limit) }.to_a
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.rpop(redis_key))
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.del(redis_key) }
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.llen(redis_key) }
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 ||= Searchkick.with_redis { |r| Gem::Version.new(r.info["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.scard(batches_key) }
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.srem(batches_key, [batch_id]) }
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.sadd(batches_key, [batch_id]) }
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,
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "5.2.0"
2
+ VERSION = "5.2.1"
3
3
  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: 5.2.0
4
+ version: 5.2.1
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-02-09 00:00:00.000000000 Z
11
+ date: 2023-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel