searchkick 6.0.0 → 6.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68ff79660fdc9912b13ca4b1d3ddc2f48c0815c7a7ca2a9bfa9eb9afa207426a
4
- data.tar.gz: 2822d89726c08c3a43e99fc8c886db17c3ee62d08580a032f5f608d2bc949df0
3
+ metadata.gz: 5ab26ce5fc3070a9d192dfae97f5f0fbf7ae98757973b3309582294d48873e87
4
+ data.tar.gz: 5841a4e05ba26647dec8fe682f6dbf154164060662054eea3ac2e57364535aec
5
5
  SHA512:
6
- metadata.gz: fd2f6d15134a97a4a000641c58d94e38ac1988cd3ba8ced152044dc42ae170b63f26a3a38409a4de8b0dded2473a9ccc5a0116b5753bf6b09233701d47d192cf
7
- data.tar.gz: 4a6d0b873941feaba860f3ef5cfd1ea11ebcaa9f462040f1622d910f44189e25c0a94a3ad13963143c131b2f92de7a17afe31a921c0791ea8538893d9163f819
6
+ metadata.gz: c8c7e037662b690f3ae3c04690f1fda2e9659fc8af6d3ded3f9b12d5e1551eb7f26eab5bfd48170edbcd112f86d59296693a139ccf20387a2d9ad0aa83829da5
7
+ data.tar.gz: 004f3464ad8ccdaa2d7242f333d93c630c902ce670d25386d692afe324f151ee0c5c754b958e813cb1ce19447568e2bad2057545fcfebcc752d27346d66009db
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 6.0.1 (2025-10-24)
2
+
3
+ - Fixed `to_json` method for `HashWrapper`
4
+
1
5
  ## 6.0.0 (2025-10-19)
2
6
 
3
7
  - Added new query builder API (similar to Active Record)
@@ -12,6 +16,7 @@
12
16
  - Changed async reindex to use ranges for numeric primary keys with Active Record
13
17
  - Fixed error with `case_sensitive` option and synonyms
14
18
  - Removed default quantization for `knn` option for Elasticsearch 8.14+
19
+ - Removed `results` method (use `to_a` instead)
15
20
  - Removed `execute` option and method (no longer needed)
16
21
  - Removed dependency on Hashie
17
22
  - Deprecated `conversions` option in favor of `conversions_v2`
data/README.md CHANGED
@@ -107,24 +107,11 @@ fields(:name, :brand)
107
107
  Where
108
108
 
109
109
  ```ruby
110
- where(
111
- expires_at: {gt: Time.now}, # lt, gte, lte also available
112
- orders_count: 1..10, # equivalent to {gte: 1, lte: 10}
113
- aisle_id: [25, 30], # in
114
- store_id: {not: 2}, # not
115
- aisle_id: {not: [25, 30]}, # not in
116
- user_ids: {all: [1, 3]}, # all elements in array
117
- category: {like: "%frozen%"}, # like
118
- category: {ilike: "%frozen%"}, # ilike
119
- category: /frozen .+/, # regexp
120
- category: {prefix: "frozen"}, # prefix
121
- store_id: {exists: true}, # exists
122
- _not: {store_id: 1}, # negate a condition
123
- _or: [{in_stock: true}, {backordered: true}],
124
- _and: [{in_stock: true}, {backordered: true}]
125
- )
110
+ where(store_id: 1, expires_at: Time.now..)
126
111
  ```
127
112
 
113
+ [These types of filters are supported](#filtering)
114
+
128
115
  Order
129
116
 
130
117
  ```ruby
@@ -184,6 +171,86 @@ results.response
184
171
 
185
172
  **Note:** By default, Elasticsearch and OpenSearch [limit paging](#deep-paging) to the first 10,000 results for performance. This applies to the total count as well.
186
173
 
174
+ ### Filtering
175
+
176
+ Equal
177
+
178
+ ```ruby
179
+ where(store_id: 1)
180
+ ```
181
+
182
+ Not equal
183
+
184
+ ```ruby
185
+ where.not(store_id: 2)
186
+ ```
187
+
188
+ Greater than (`gt`), less than (`lt`), greater than or equal (`gte`), less than or equal (`lte`)
189
+
190
+ ```ruby
191
+ where(expires_at: {gt: Time.now})
192
+ ```
193
+
194
+ Range
195
+
196
+ ```ruby
197
+ where(orders_count: 1..10)
198
+ ```
199
+
200
+ In
201
+
202
+ ```ruby
203
+ where(aisle_id: [25, 30])
204
+ ```
205
+
206
+ Not in
207
+
208
+ ```ruby
209
+ where.not(aisle_id: [25, 30])
210
+ ```
211
+
212
+ Contains all
213
+
214
+ ```ruby
215
+ where(user_ids: {all: [1, 3]})
216
+ ```
217
+
218
+ Like
219
+
220
+ ```ruby
221
+ where(category: {like: "%frozen%"})
222
+ ```
223
+
224
+ Case-insensitive like
225
+
226
+ ```ruby
227
+ where(category: {ilike: "%frozen%"})
228
+ ```
229
+
230
+ Regular expression
231
+
232
+ ```ruby
233
+ where(category: /frozen .+/)
234
+ ```
235
+
236
+ Prefix
237
+
238
+ ```ruby
239
+ where(category: {prefix: "frozen"})
240
+ ```
241
+
242
+ Exists
243
+
244
+ ```ruby
245
+ where(store_id: {exists: true})
246
+ ```
247
+
248
+ Combine filters with OR
249
+
250
+ ```ruby
251
+ where(_or: [{in_stock: true}, {backordered: true}])
252
+ ```
253
+
187
254
  ### Boosting
188
255
 
189
256
  Boost important fields
@@ -1492,8 +1559,10 @@ And create an initializer with:
1492
1559
 
1493
1560
  ```ruby
1494
1561
  class SearchSerializer
1562
+ CODER = JSON::Coder.new { |v, _| v.is_a?(Time) ? v.as_json : v }
1563
+
1495
1564
  def dump(object)
1496
- JSON.generate(object)
1565
+ CODER.generate(object)
1497
1566
  end
1498
1567
  end
1499
1568
 
@@ -12,6 +12,10 @@ module Searchkick
12
12
  @attributes
13
13
  end
14
14
 
15
+ def to_json
16
+ @attributes.to_json
17
+ end
18
+
15
19
  def method_missing(name, ...)
16
20
  if @attributes.key?(name.to_s)
17
21
  self[name]
@@ -589,7 +589,7 @@ module Searchkick
589
589
  end
590
590
 
591
591
  def pluck(*keys)
592
- if @options[:load] == false
592
+ if !loaded? && @options[:load] == false
593
593
  select(*keys).send(:private_execute).pluck(*keys)
594
594
  else
595
595
  private_execute.pluck(*keys)
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "6.0.0"
2
+ VERSION = "6.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane