jay_api 29.0.0 → 29.1.0

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: 6fd8321f31af66d102817b6a53a6de84ec3bb5a784e9344e682b815194eb9c02
4
- data.tar.gz: 5b1493b8853afdb9492c878c1a0f4e660966a6028b52c4495d33dbddbbca6755
3
+ metadata.gz: 1f1153d9c1260eec0e2b267dbf5ea63074c388f5a72ee4473013322e380388aa
4
+ data.tar.gz: 3e329829a95831222b1d5111de202b1d0a4160b22889f549e81bde8f4c072b10
5
5
  SHA512:
6
- metadata.gz: de63cf5cd907e7fb7ada754962df8b7d72c2592524a1efc0f09f1dfbd9527d945a49453fed1ae0727e14790fc2ce70e0e490acd0829d0d7731867aaf5f8e8c50
7
- data.tar.gz: 76ec356377a73fc6922d9d4adbd237e2e62e260eff3867e5a4e2494d480c64b4d50de69b5e84ab22a9f731f934658d25f68a5a2a7d8ed87e5e01ba664783334a
6
+ metadata.gz: 87460d91ba4fcee072ce01d7b4d9a71d926cf6c1d6a02aa5cb1d8fda8e6ed1e09d510de9e411d980594ee22991a420abf784c60eface6e9d9fa51f1e9563ddf1
7
+ data.tar.gz: 6e64661a3fe9cd20cb9f437e3310d5ccd6ac85d8931a681d571224bec564a51c738a7a198d054b40c8effa2af2514423f64985acdcad8994d2ee89f98df047b6
data/CHANGELOG.md CHANGED
@@ -8,6 +8,15 @@ Please mark backwards incompatible changes with an exclamation mark at the start
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [29.1.0] - 2025-10-22
12
+
13
+ ### Added
14
+ - The `#bool` method to the `QueryBuilder::QueryClauses::Bool` class. This
15
+ allows boolean clauses to be nested.
16
+ - `QueryBuilder#sort` can now receive either the direction of the sorting (`asc`
17
+ or `desc`) or a `Hash` with advanced sorting options. These are relayed
18
+ directly to Elasticsearch.
19
+
11
20
  ## [29.0.0] - 2025-08-28
12
21
 
13
22
  ### Changed
@@ -61,6 +61,19 @@ module JayAPI
61
61
  add_boolean_clause(:must_not, &block)
62
62
  end
63
63
 
64
+ # Adds a nested +Boolean+ clause to the receiver. For this to work the
65
+ # receiver must have an active sub-clause (for example +must+).
66
+ # @yield [JayAPI::Elasticsearch::QueryBuilder::QueryClauses::Bool]
67
+ # Yields the nested boolean clause to the given block.
68
+ # @return [JayAPI::Elasticsearch::QueryBuilder::QueryClauses::Bool]
69
+ # Returns the nested boolean clause.
70
+ def bool(&block)
71
+ nested_bool = self.class.new
72
+ self << nested_bool
73
+ block&.call(nested_bool)
74
+ nested_bool
75
+ end
76
+
64
77
  # Adds a clause to the current sub-clause of the boolean clause.
65
78
  # @param [JayAPI::Elasticsearch::QueryBuilder::QueryClauses::QueryClause]
66
79
  # query_clause The query clause to add.
@@ -64,13 +64,22 @@ module JayAPI
64
64
  # query_builder.sort(age: 'desc')
65
65
  #
66
66
  # Both will produce the same +sort+ clause.
67
+ #
68
+ # It is also possible to pass a Hash with advanced sorting options, for
69
+ # example:
70
+ #
71
+ # query_builder.sort(price: { order: :desc, missing: :_last })
72
+ #
67
73
  # @param [Hash] sort A Hash whose keys are the name of the fields
68
- # and the keys are the direction of the sorting, either +asc+ or
69
- # +desc+.
74
+ # and whose values are either the direction of the sorting (+:asc+ or
75
+ # +:desc+) or a Hash with advanced sort options.
76
+ # @see https://www.elastic.co/docs/reference/elasticsearch/rest-apis/sort-search-results
70
77
  # @return [QueryBuilder] itself so that other methods can be chained.
71
78
  def sort(sort)
72
79
  check_argument(sort, 'sort', Hash)
73
- @sort.merge!(sort)
80
+ @sort.merge!(
81
+ sort.transform_values { |value| value.is_a?(Hash) ? value : { order: value } }
82
+ )
74
83
  self
75
84
  end
76
85
 
@@ -184,11 +193,7 @@ module JayAPI
184
193
  query_hash[:_source] = @source unless @source.nil?
185
194
  query_hash[:query] = query.to_h
186
195
 
187
- if @sort.any?
188
- query_hash[:sort] = @sort.map do |field, direction|
189
- { field => { order: direction } }
190
- end
191
- end
196
+ query_hash[:sort] = @sort.map { |field, ordering| { field => ordering } } if @sort.any?
192
197
 
193
198
  if @collapse
194
199
  query_hash[:collapse] = {
@@ -2,5 +2,5 @@
2
2
 
3
3
  module JayAPI
4
4
  # JayAPI gem's semantic version
5
- VERSION = '29.0.0'
5
+ VERSION = '29.1.0'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jay_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 29.0.0
4
+ version: 29.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Accenture-Industry X
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-08-28 00:00:00.000000000 Z
12
+ date: 2025-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport