jay_api 29.0.0 → 29.2.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d730f73b47853cc0604558da470c22fe1818b492dadf61c4c3a0dd6cb567f00d
|
|
4
|
+
data.tar.gz: a5a7476fd2d5c402d00580e2f5420a201e395076b15659e70b3aa225002c0dfb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 38eecb188ae827dd18ad9aaf03ef9466f0cb09d6732e559d042ccdb299bf27f9333527553658b6722c1e932cd2de238df8df63519a03c41e9e74dbc61a70361c
|
|
7
|
+
data.tar.gz: 419aa1470d24e060b25250655e515b6c2a72c0f558015406b17ea5a571fb33c978e9f624821441f9756fd8922f45315bfd2960c2bd8cb4ece4dbc825201a248f
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,23 @@ Please mark backwards incompatible changes with an exclamation mark at the start
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [29.2.0] - 2025-12-09
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- A `#clone` method to `Elasticsearch::QueryBuilder` that properly clones the
|
|
15
|
+
`QueryBuilder` and its nested objects.
|
|
16
|
+
- ActiveSupport's `#present?`, `#presence` and `#blank?` methods can now be used
|
|
17
|
+
in ERB configuration files.
|
|
18
|
+
|
|
19
|
+
## [29.1.0] - 2025-10-22
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- The `#bool` method to the `QueryBuilder::QueryClauses::Bool` class. This
|
|
23
|
+
allows boolean clauses to be nested.
|
|
24
|
+
- `QueryBuilder#sort` can now receive either the direction of the sorting (`asc`
|
|
25
|
+
or `desc`) or a `Hash` with advanced sorting options. These are relayed
|
|
26
|
+
directly to Elasticsearch.
|
|
27
|
+
|
|
11
28
|
## [29.0.0] - 2025-08-28
|
|
12
29
|
|
|
13
30
|
### 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
|
|
69
|
-
# +
|
|
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!(
|
|
80
|
+
@sort.merge!(
|
|
81
|
+
sort.transform_values { |value| value.is_a?(Hash) ? value : { order: value } }
|
|
82
|
+
)
|
|
74
83
|
self
|
|
75
84
|
end
|
|
76
85
|
|
|
@@ -118,6 +127,16 @@ module JayAPI
|
|
|
118
127
|
)
|
|
119
128
|
end
|
|
120
129
|
|
|
130
|
+
# @return [JayAPI::Elasticsearch::QueryBuilder] A copy of the receiver.
|
|
131
|
+
def clone
|
|
132
|
+
copy = super
|
|
133
|
+
copy.source = @source.clone # source can be an Array or a Hash
|
|
134
|
+
copy.sort = @sort.clone # sort is a Hash
|
|
135
|
+
copy.query = query.clone
|
|
136
|
+
copy.aggregations = aggregations.clone
|
|
137
|
+
copy
|
|
138
|
+
end
|
|
139
|
+
|
|
121
140
|
protected
|
|
122
141
|
|
|
123
142
|
attr_writer :from, :size, :source, :collapse, :sort, :query, :aggregations
|
|
@@ -184,11 +203,7 @@ module JayAPI
|
|
|
184
203
|
query_hash[:_source] = @source unless @source.nil?
|
|
185
204
|
query_hash[:query] = query.to_h
|
|
186
205
|
|
|
187
|
-
if @sort.any?
|
|
188
|
-
query_hash[:sort] = @sort.map do |field, direction|
|
|
189
|
-
{ field => { order: direction } }
|
|
190
|
-
end
|
|
191
|
-
end
|
|
206
|
+
query_hash[:sort] = @sort.map { |field, ordering| { field => ordering } } if @sort.any?
|
|
192
207
|
|
|
193
208
|
if @collapse
|
|
194
209
|
query_hash[:collapse] = {
|
data/lib/jay_api/version.rb
CHANGED
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.
|
|
4
|
+
version: 29.2.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-
|
|
12
|
+
date: 2025-12-09 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|