chewy 7.3.5 → 7.3.6

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: bcb16d3ca40da336d2445b114cff68c634f6091c66352f459bafbce6794aa864
4
- data.tar.gz: bedb5bcc0520a6e6b26c9605cd2574a102469d6043f9ce39c55aeae61d1fa30b
3
+ metadata.gz: e5405b97585dccb630ef95340245a390ff7ffe19a1a27e57a35b4f4d6844e2e0
4
+ data.tar.gz: 91570a2fd199d511bf40caf473d8000504cae38a4bb4b68c6f767913033f7234
5
5
  SHA512:
6
- metadata.gz: 46eef11ff1d3acf7d3717fa5975071f06ae0fa03f638c82be7f5e687efababf39c67d1cfd7d376854c556ea0227876743b5e7e0ac845df1f72f1ea8bab510d70
7
- data.tar.gz: '0889aee5bc0d928dbff9b1894064c5fe3f8a572b7f3e434034b8fe32a7bcece1d48a86673cad80fcc40b2a6a41342f7195905d90d87e7f6a85d9bb5e1b8ab4a2'
6
+ metadata.gz: 8441a05d5a3c55834f7380a1e10b3acb4f01f17b6cafc45e3ccead13f0d7c2a6485447c2bc8461ae5c91b37b36c4d57f140f76cb993ca63777195d64237d8432
7
+ data.tar.gz: 3571db3d5fa632d6ee9c10105578ca8f805090e375372f1ad98a192dca440536f27559be2439d7e75c8ab833f596fc61758d464696ec4ee47942ff29fbffa6d5
data/CHANGELOG.md CHANGED
@@ -8,6 +8,16 @@
8
8
 
9
9
  ### Bugs Fixed
10
10
 
11
+ ## 7.3.5 (2023-12-13)
12
+
13
+ ### New Features
14
+
15
+ * [#890](https://github.com/toptal/chewy/pull/890): Add the [`knn`](https://www.elastic.co/guide/en/elasticsearch/reference/current/knn-search.html) option to the request. ([@jkostolansky][])
16
+
17
+ ### Changes
18
+
19
+ ### Bugs Fixed
20
+
11
21
  ## 7.3.5 (2023-12-06)
12
22
 
13
23
  ### New Features
@@ -0,0 +1,16 @@
1
+ require 'chewy/search/parameters/storage'
2
+
3
+ module Chewy
4
+ module Search
5
+ class Parameters
6
+ # Just a standard hash storage. Nothing to see here.
7
+ #
8
+ # @see Chewy::Search::Parameters::HashStorage
9
+ # @see Chewy::Search::Request#knn
10
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/knn-search.html
11
+ class Knn < Storage
12
+ include HashStorage
13
+ end
14
+ end
15
+ end
16
+ end
@@ -20,7 +20,7 @@ module Chewy
20
20
  UNDEFINED = Class.new.freeze
21
21
  EVERFIELDS = %w[_index _type _id _parent _routing].freeze
22
22
  DELEGATED_METHODS = %i[
23
- query filter post_filter order reorder docvalue_fields
23
+ query filter post_filter knn order reorder docvalue_fields
24
24
  track_scores track_total_hits request_cache explain version profile
25
25
  search_type preference limit offset terminate_after
26
26
  timeout min_score source stored_fields search_after
@@ -41,7 +41,7 @@ module Chewy
41
41
  EXTRA_STORAGES = %i[aggs suggest].freeze
42
42
  # An array of storage names that are changing the returned hist collection in any way.
43
43
  WHERE_STORAGES = %i[
44
- query filter post_filter none min_score rescore indices_boost collapse
44
+ query filter post_filter knn none min_score rescore indices_boost collapse
45
45
  ].freeze
46
46
 
47
47
  delegate :hits, :wrappers, :objects, :records, :documents,
@@ -520,7 +520,18 @@ module Chewy
520
520
  # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/collapse-search-results.html
521
521
  # @param value [Hash]
522
522
  # @return [Chewy::Search::Request]
523
- %i[request_cache search_type preference timeout limit offset terminate_after min_score ignore_unavailable collapse].each do |name|
523
+ #
524
+ # @!method knn(value)
525
+ # Replaces the value of the `knn` request part.
526
+ #
527
+ # @example
528
+ # PlacesIndex.knn(field: :vector, query_vector: [4, 2], k: 5, num_candidates: 50)
529
+ # # => <PlacesIndex::Query {..., :body=>{:knn=>{"field"=>:vector, "query_vector"=>[4, 2], "k"=>5, "num_candidates"=>50}}}>
530
+ # @see Chewy::Search::Parameters::Knn
531
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/knn-search.html
532
+ # @param value [Hash]
533
+ # @return [Chewy::Search::Request]
534
+ %i[request_cache search_type preference timeout limit offset terminate_after min_score ignore_unavailable collapse knn].each do |name|
524
535
  define_method name do |value|
525
536
  modify(name) { replace!(value) }
526
537
  end
data/lib/chewy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Chewy
2
- VERSION = '7.3.5'.freeze
2
+ VERSION = '7.3.6'.freeze
3
3
  end
@@ -0,0 +1,5 @@
1
+ require 'chewy/search/parameters/hash_storage_examples'
2
+
3
+ describe Chewy::Search::Parameters::Knn do
4
+ it_behaves_like :hash_storage, :knn
5
+ end
@@ -314,14 +314,16 @@ describe Chewy::Search::Request do
314
314
  end
315
315
  end
316
316
 
317
- describe '#collapse' do
318
- specify { expect(subject.collapse(foo: {bar: 42}).render[:body]).to include(collapse: {'foo' => {bar: 42}}) }
319
- specify do
320
- expect(subject.collapse(foo: {bar: 42}).collapse(moo: {baz: 43}).render[:body])
321
- .to include(collapse: {'moo' => {baz: 43}})
317
+ %i[collapse knn].each do |name|
318
+ describe "##{name}" do
319
+ specify { expect(subject.send(name, foo: {bar: 42}).render[:body]).to include(name => {'foo' => {bar: 42}}) }
320
+ specify do
321
+ expect(subject.send(name, foo: {bar: 42}).send(name, moo: {baz: 43}).render[:body])
322
+ .to include(name => {'moo' => {baz: 43}})
323
+ end
324
+ specify { expect(subject.send(name, foo: {bar: 42}).send(name, nil).render[:body]).to be_blank }
325
+ specify { expect { subject.send(name, foo: {bar: 42}) }.not_to change { subject.render } }
322
326
  end
323
- specify { expect(subject.collapse(foo: {bar: 42}).collapse(nil).render[:body]).to be_blank }
324
- specify { expect { subject.collapse(foo: {bar: 42}) }.not_to change { subject.render } }
325
327
  end
326
328
 
327
329
  describe '#docvalue_fields' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chewy
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.5
4
+ version: 7.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toptal, LLC
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-12-06 00:00:00.000000000 Z
12
+ date: 2023-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: database_cleaner
@@ -324,6 +324,7 @@ files:
324
324
  - lib/chewy/search/parameters/ignore_unavailable.rb
325
325
  - lib/chewy/search/parameters/indices.rb
326
326
  - lib/chewy/search/parameters/indices_boost.rb
327
+ - lib/chewy/search/parameters/knn.rb
327
328
  - lib/chewy/search/parameters/limit.rb
328
329
  - lib/chewy/search/parameters/load.rb
329
330
  - lib/chewy/search/parameters/min_score.rb
@@ -419,6 +420,7 @@ files:
419
420
  - spec/chewy/search/parameters/ignore_unavailable_spec.rb
420
421
  - spec/chewy/search/parameters/indices_spec.rb
421
422
  - spec/chewy/search/parameters/integer_storage_examples.rb
423
+ - spec/chewy/search/parameters/knn_spec.rb
422
424
  - spec/chewy/search/parameters/limit_spec.rb
423
425
  - spec/chewy/search/parameters/load_spec.rb
424
426
  - spec/chewy/search/parameters/min_score_spec.rb
@@ -537,6 +539,7 @@ test_files:
537
539
  - spec/chewy/search/parameters/ignore_unavailable_spec.rb
538
540
  - spec/chewy/search/parameters/indices_spec.rb
539
541
  - spec/chewy/search/parameters/integer_storage_examples.rb
542
+ - spec/chewy/search/parameters/knn_spec.rb
540
543
  - spec/chewy/search/parameters/limit_spec.rb
541
544
  - spec/chewy/search/parameters/load_spec.rb
542
545
  - spec/chewy/search/parameters/min_score_spec.rb