jay_api 29.10.0 → 29.11.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: 29f1af4da5bd52cd5012da50bc4933a30cd8d3d7682d4301bab18dfb429d090c
4
- data.tar.gz: 86924bc855b991f2678cce3d3f023e8958f3beb725fb154429ad5667c705b78c
3
+ metadata.gz: af422ade60e62cb63cd97d8fd51892cd9876143e8fee61da5ac64666ad70e4ed
4
+ data.tar.gz: bb7c1cbf24070575ea3db15d5056e7b22389b62e1199c7243c5243aa07722cf6
5
5
  SHA512:
6
- metadata.gz: d4401b8bea8090b4f21182689b336d65256efe4136327c23f1418aa93a88b8bd3d15c364423838b8e29709f2edc4ebae5d99953a8125bd97ae268b4a2fc2de46
7
- data.tar.gz: ce39feece636e38b932e3b100f814f7ecba3fb3c7c870a6c8a7d12cbba4c24e5c9c32646b6ede2d59f86f73f434b617364b65eaf88a5722582ce9b28c54cc9ad
6
+ metadata.gz: ce6602395fb91182c762e7bcf6d32a2391731087af461b6b67a6f2ed2d563b65bd46f011eae1bd04f0ee45e337749567098257616c41265d46b70a39d6b3d33c
7
+ data.tar.gz: 8344f2770b7c707a045d01159ff71c91fefe3058a742177e1a670a707a956fc9bd190b512f1ae56f23c70f39287eeac633e73367ef57fd02745f07d0e8135fd3
data/CHANGELOG.md CHANGED
@@ -8,6 +8,13 @@ Please mark backwards incompatible changes with an exclamation mark at the start
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [29.11.0] - 2026-09-03
12
+
13
+ ### Added
14
+ - The `_source` parameter for Elasticsearch's `TopHits` aggregation.
15
+ - The `sort` parameter for Elasticsearch's `TopHits` aggregation.
16
+ - The `missing` parameter for Elasticsearch's `Terms` aggregation.
17
+
11
18
  ## [29.10.0] - 2026-08-21
12
19
 
13
20
  ### Added
@@ -14,7 +14,7 @@ module JayAPI
14
14
  # Information about this type of aggregation can be found in:
15
15
  # https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
16
16
  class Terms < ::JayAPI::Elasticsearch::QueryBuilder::Aggregations::Aggregation
17
- attr_reader :field, :script, :size, :order
17
+ attr_reader :field, :script, :size, :order, :missing
18
18
 
19
19
  # @param [String] name The name used by Elasticsearch to identify each
20
20
  # of the aggregations.
@@ -29,9 +29,15 @@ module JayAPI
29
29
  # aggregation. By default, the +terms+ aggregation orders terms by
30
30
  # descending document +_count+. This can be changed by providing a
31
31
  # custom +order+ hash.
32
+ # @param [String] missing The value to use for documents that are
33
+ # missing a value in the given +field+ or for whom the +script+
34
+ # returns +null+. When +missing+ is not given, such documents are
35
+ # ignored.
32
36
  # @raise [ArgumentError] If neither a +field+ nor a +script+ are given
33
37
  # or if both of them are given. Only one should be present.
34
- def initialize(name, field: nil, script: nil, size: nil, order: nil)
38
+ # rubocop:disable Metrics/ParameterLists -- Constraint by Elasticsearch's design
39
+ # :reek:LongParameterList -- Constraint by Elasticsearch's design
40
+ def initialize(name, field: nil, script: nil, size: nil, order: nil, missing: nil)
35
41
  if (field.present? && script.present?) || (field.blank? && script.blank?)
36
42
  raise ArgumentError, "Either 'field' or 'script' must be provided"
37
43
  end
@@ -42,13 +48,16 @@ module JayAPI
42
48
  @script = script
43
49
  @size = size
44
50
  @order = order
51
+ @missing = missing
45
52
  end
46
53
 
54
+ # rubocop:enable Metrics/ParameterLists
55
+
47
56
  # @return [self] A copy of the receiver.
48
57
  def clone
49
- self.class.new(name, field: field, script: script, size: size, order: order&.deep_dup).tap do |copy|
50
- copy.aggregations = aggregations.clone
51
- end
58
+ self.class.new(
59
+ name, field: field, script: script, size: size, order: order&.deep_dup, missing: missing
60
+ ).tap { |copy| copy.aggregations = aggregations.clone }
52
61
  end
53
62
 
54
63
  # @return [Hash] The Hash representation of the +Aggregation+.
@@ -60,7 +69,8 @@ module JayAPI
60
69
  field: field,
61
70
  size: size,
62
71
  script: script&.to_h,
63
- order: order
72
+ order: order,
73
+ missing: missing
64
74
  }.compact
65
75
  }
66
76
  end
@@ -15,20 +15,32 @@ module JayAPI
15
15
  # Information on this type of aggregation can be found here:
16
16
  # https://www.elastic.co/docs/reference/aggregations/search-aggregations-metrics-top-hits-aggregation
17
17
  class TopHits < ::JayAPI::Elasticsearch::QueryBuilder::Aggregations::Aggregation
18
- attr_reader :size
18
+ attr_reader :size, :sort, :_source
19
19
 
20
20
  # @param [String] name The name used by Elasticsearch to identify each
21
21
  # of the aggregations.
22
22
  # @param [String] size The number of hits that will be returned.
23
- def initialize(name, size:)
23
+ # @param [Hash] sort How to sort the documents to determine the top
24
+ # hits. When not specified the documents are sorted by the score of
25
+ # the main query.
26
+ # @param [FalseClass, String, Array<String>, Hash] _source Expression
27
+ # used for source filtering.
28
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#source-filtering
29
+ # Elasticsearch's documentation for more information on what kind of
30
+ # expressions are allowed.
31
+ # rubocop:disable-next Lint/UnderscorePrefixedVariableName -- to match Elasticsearch's name
32
+ def initialize(name, size:, sort: nil, _source: nil)
24
33
  super(name)
25
34
 
26
35
  @size = size
36
+ @sort = sort
37
+ @_source = _source
27
38
  end
28
39
 
29
40
  # @return [self] A copy of the receiver.
30
41
  def clone
31
- copy = self.class.new(name, size: size)
42
+ optional_params = { sort: sort.deep_dup, _source: _source.deep_dup }.compact
43
+ copy = self.class.new(name, size: size, **optional_params)
32
44
  copy.aggregations = aggregations.clone
33
45
  copy
34
46
  end
@@ -39,8 +51,10 @@ module JayAPI
39
51
  super do
40
52
  {
41
53
  top_hits: {
42
- size: size
43
- }
54
+ size: size,
55
+ sort: sort.deep_dup,
56
+ _source: _source.deep_dup
57
+ }.compact
44
58
  }
45
59
  end
46
60
  end
@@ -32,11 +32,9 @@ module JayAPI
32
32
 
33
33
  # Adds a +terms+ type aggregation. For information about the parameters
34
34
  # @see JayAPI::Elasticsearch::QueryBuilder::Aggregations::Terms#initialize
35
- def terms(name, field: nil, script: nil, size: nil, order: nil)
35
+ def terms(name, **params)
36
36
  add(
37
- ::JayAPI::Elasticsearch::QueryBuilder::Aggregations::Terms.new(
38
- name, field: field, script: script, size: size, order: order
39
- )
37
+ ::JayAPI::Elasticsearch::QueryBuilder::Aggregations::Terms.new(name, **params)
40
38
  )
41
39
  end
42
40
 
@@ -72,8 +70,8 @@ module JayAPI
72
70
 
73
71
  # Adds a +top_hits+ type aggregation. For more information about the parameters
74
72
  # @see JayAPI::Elasticsearch::QueryBuilder::Aggregations::TopHits#initialize
75
- def top_hits(name, size:)
76
- add(::JayAPI::Elasticsearch::QueryBuilder::Aggregations::TopHits.new(name, size: size))
73
+ def top_hits(name, **params)
74
+ add(::JayAPI::Elasticsearch::QueryBuilder::Aggregations::TopHits.new(name, **params))
77
75
  end
78
76
 
79
77
  # Adds an +scripted_metric+ type aggregation. For information about the parameters
@@ -2,5 +2,5 @@
2
2
 
3
3
  module JayAPI
4
4
  # JayAPI gem's semantic version
5
- VERSION = '29.10.0'
5
+ VERSION = '29.11.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.10.0
4
+ version: 29.11.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: 2026-08-21 00:00:00.000000000 Z
12
+ date: 2026-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport