jay_api 27.1.0 → 27.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: 773086b4ced206a7ccecba655665b5d525fc68f0552c5be72abdfa3eb07d5585
4
- data.tar.gz: aecb7f4b0af0a692bbc0b2ab95ea7184e5d743a1f10d268c769d8d8d9f781453
3
+ metadata.gz: 3314debaa7f484d22d094d74cc7a8af9b14b3a1e08e52f95cece7b8e1b73cc14
4
+ data.tar.gz: 6535032e2b1ddb1b3e3b8f7cffff77e28e5c107c93832f9b6d93f720e663c858
5
5
  SHA512:
6
- metadata.gz: 7897a7adddd0b69691fdf513dac2dcb2a92a1cc4f47fee243da4e9325587ff00aa78d167bd93df728e13eab3955af58224c45103903c5aa256eed7267705819a
7
- data.tar.gz: e7e7e6aa94c21d4e69ed7e586da6910dd5048531a68c3613b68d738fb1dcd69bc0c52ef1958e7ac28e95abcfd1fd6d742e2e4aef42b97f55f683db58354a85e8
6
+ metadata.gz: 4c7a1d9da9204610f5b1be328b225132690c370128bf8c35d91f765e7bd08f0a8d3b136c77adfda22cf181441fec1ba274dad0ad1570482ac78d452862146fbd
7
+ data.tar.gz: 4e5edc12ed9541991f3effd901c4c188893664ba89aebcb439b49bfc2291a97cc72ebc8781e4c984826c5d62ca2c3e53e8d4b199658f527e6b3c95f1eb34699c
data/CHANGELOG.md CHANGED
@@ -8,6 +8,12 @@ Please mark backwards incompatible changes with an exclamation mark at the start
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [27.2.0] - 2025-02-28
12
+
13
+ ### Added
14
+ - `QueryBuilder#source` can now take `false`, `Array` and `Hash` in addition to
15
+ simple strings.
16
+
11
17
  ## [27.1.0] - 2025-02-19
12
18
 
13
19
  ### Added
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'errors/elasticsearch_error'
4
+ require_relative 'errors/end_of_query_results_error'
5
+ require_relative 'errors/query_execution_error'
6
+ require_relative 'errors/query_execution_failure'
7
+ require_relative 'errors/query_execution_timeout'
8
+ require_relative 'errors/search_after_error'
9
+
10
+ module JayAPI
11
+ module Elasticsearch
12
+ # Namespace for all error classes related to Elasticsearch
13
+ module Errors; end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'errors/query_builder_error'
4
+
5
+ module JayAPI
6
+ module Elasticsearch
7
+ class QueryBuilder
8
+ # Namespace for the error classes related to the QueryBuilder
9
+ module Errors; end
10
+ end
11
+ end
12
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'query_builder/aggregations'
4
+ require_relative 'query_builder/errors'
4
5
  require_relative 'query_builder/query_clauses'
5
6
  require_relative 'query_builder/script'
6
7
 
@@ -83,10 +84,13 @@ module JayAPI
83
84
  end
84
85
 
85
86
  # Adds a +_source+ clause to the query.
86
- # @param [String] filter_expr Expression used for filtering source.
87
+ # @param [FalseClass, String, Array<String>, Hash] filter_expr Expression
88
+ # used for source filtering.
89
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#source-filtering
90
+ # For more information on what kind of expressions are allowed.
87
91
  # @return [QueryBuilder] itself so that other methods can be chained.
88
92
  def source(filter_expr)
89
- check_argument(filter_expr, 'source', String)
93
+ check_argument(filter_expr, 'source', FalseClass, String, Array, Hash)
90
94
  @source = filter_expr
91
95
  self
92
96
  end
@@ -149,12 +153,15 @@ module JayAPI
149
153
  # @param [Object] value The value of the argument.
150
154
  # @param [String] argument_name The name of the argument (for the error
151
155
  # message).
152
- # @param [Class] expected_type The expected type of +value+
153
- # @raise [ArgumentError] If the value is not an instance of the class.
154
- def check_argument(value, argument_name, expected_type)
155
- return if value.is_a?(expected_type)
156
-
157
- raise ArgumentError, "Expected `#{argument_name}` to be #{expected_type}, #{value.class} given"
156
+ # @param [Class, Array<Class>] allowed_types The list of classes that
157
+ # +value+ might have.
158
+ # @raise [ArgumentError] If the value is not an instance of the any of the
159
+ # classes in +allowed_types+.
160
+ def check_argument(value, argument_name, *allowed_types)
161
+ return if allowed_types.any? { |allowed_type| value.is_a?(allowed_type) }
162
+
163
+ raise ArgumentError, "Expected `#{argument_name}` to be one of: " \
164
+ "#{allowed_types.map(&:to_s).join(', ')} but #{value.class} was given"
158
165
  end
159
166
 
160
167
  # Checks that the given argument is positive (>= 0)
@@ -174,7 +181,7 @@ module JayAPI
174
181
  query_hash = {}
175
182
  query_hash[:from] = @from if @from
176
183
  query_hash[:size] = @size if @size
177
- query_hash[:_source] = @source if @source
184
+ query_hash[:_source] = @source unless @source.nil?
178
185
  query_hash[:query] = query.to_h
179
186
 
180
187
  if @sort.any?
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'elasticsearch/async'
4
+ require_relative 'elasticsearch/batch_counter'
5
+ require_relative 'elasticsearch/client'
6
+ require_relative 'elasticsearch/client_factory'
7
+ require_relative 'elasticsearch/errors'
8
+ require_relative 'elasticsearch/index'
9
+ require_relative 'elasticsearch/query_builder'
10
+ require_relative 'elasticsearch/query_results'
11
+ require_relative 'elasticsearch/response'
12
+ require_relative 'elasticsearch/search_after_results'
13
+ require_relative 'elasticsearch/tasks'
14
+ require_relative 'elasticsearch/time'
15
+
16
+ module JayAPI
17
+ # Namespace for all Elasticsearch related classes.
18
+ module Elasticsearch; end
19
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module JayAPI
4
4
  # JayAPI gem's semantic version
5
- VERSION = '27.1.0'
5
+ VERSION = '27.2.0'
6
6
  end
data/lib/jay_api.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'jay_api/version'
4
4
 
5
5
  require_relative 'jay_api/rspec'
6
+ require_relative 'jay_api/elasticsearch'
6
7
 
7
8
  # Top-level namespace for the Gem
8
9
  module JayAPI
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: 27.1.0
4
+ version: 27.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-02-19 00:00:00.000000000 Z
12
+ date: 2025-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -122,10 +122,12 @@ files:
122
122
  - lib/jay_api/abstract/geometric_wait.rb
123
123
  - lib/jay_api/abstract/wait_strategy.rb
124
124
  - lib/jay_api/configuration.rb
125
+ - lib/jay_api/elasticsearch.rb
125
126
  - lib/jay_api/elasticsearch/async.rb
126
127
  - lib/jay_api/elasticsearch/batch_counter.rb
127
128
  - lib/jay_api/elasticsearch/client.rb
128
129
  - lib/jay_api/elasticsearch/client_factory.rb
130
+ - lib/jay_api/elasticsearch/errors.rb
129
131
  - lib/jay_api/elasticsearch/errors/elasticsearch_error.rb
130
132
  - lib/jay_api/elasticsearch/errors/end_of_query_results_error.rb
131
133
  - lib/jay_api/elasticsearch/errors/query_execution_error.rb
@@ -146,6 +148,7 @@ files:
146
148
  - lib/jay_api/elasticsearch/query_builder/aggregations/terms.rb
147
149
  - lib/jay_api/elasticsearch/query_builder/aggregations/top_hits.rb
148
150
  - lib/jay_api/elasticsearch/query_builder/aggregations/value_count.rb
151
+ - lib/jay_api/elasticsearch/query_builder/errors.rb
149
152
  - lib/jay_api/elasticsearch/query_builder/errors/query_builder_error.rb
150
153
  - lib/jay_api/elasticsearch/query_builder/query_clauses.rb
151
154
  - lib/jay_api/elasticsearch/query_builder/query_clauses/bool.rb