jay_api 29.7.0 → 29.8.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 +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/jay_api/elasticsearch/client.rb +8 -0
- data/lib/jay_api/elasticsearch/index.rb +43 -0
- data/lib/jay_api/elasticsearch/query_builder/aggregations/bucket_selector.rb +2 -2
- data/lib/jay_api/elasticsearch/query_builder/aggregations/terms.rb +3 -4
- data/lib/jay_api/elasticsearch/query_builder/query_clauses/ids.rb +35 -0
- data/lib/jay_api/elasticsearch/query_builder/query_clauses/match_clauses.rb +13 -0
- data/lib/jay_api/elasticsearch/query_builder/script.rb +4 -25
- data/lib/jay_api/elasticsearch/script.rb +34 -0
- data/lib/jay_api/elasticsearch.rb +1 -0
- data/lib/jay_api/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 00a7a3dd5e1e7e2bf232e6f06c8ce6b6e39a31693f4ec2921fb56a1f14e70f63
|
|
4
|
+
data.tar.gz: 405c629691a82be4e5da822b4875494cf365195e8ccfb9653986e143cc8707f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a469997825b9876cf81c4e5944414928fe27d9c58233478556cc2923086c4837ebe5ba36033aa2a57765f05000af68f150c88978b5a3fd636769b9dddd3db6a2
|
|
7
|
+
data.tar.gz: 70e767866d629bb49eb1c2a4fd0f64ed204c68c0c1b5da704125be0c6fa29926e41ddfd1160c9ee98b78f23d99df1484d749d4ebb2ec83594823c6f778048419
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,19 @@ Please mark backwards incompatible changes with an exclamation mark at the start
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [29.8.0] - 2026-07-06
|
|
12
|
+
|
|
13
|
+
### Deprecated
|
|
14
|
+
- The `Elasticsearch::QueryBuilder::Script` class is now deprecated, please
|
|
15
|
+
use `Elasticsearch::Script` instead.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- The `#update` method to `JayAPI::Elasticsearch::Client`.
|
|
19
|
+
- The `QueryClauses::IDs` class and the corresponding `#ids` method to the
|
|
20
|
+
`MatchClauses` module. This allows the use of Elasticsearch's
|
|
21
|
+
[ids](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-ids-query)
|
|
22
|
+
query with the Query Builder.
|
|
23
|
+
|
|
11
24
|
## [29.7.0] - 2026-04-28
|
|
12
25
|
|
|
13
26
|
### Added
|
|
@@ -96,6 +96,14 @@ module JayAPI
|
|
|
96
96
|
def cluster
|
|
97
97
|
@cluster ||= ::JayAPI::Elasticsearch::Cluster.new(transport_client)
|
|
98
98
|
end
|
|
99
|
+
|
|
100
|
+
# Calls the +Elasticsearch::Client+'s #update method forwarding the given
|
|
101
|
+
# parameters. If the request fails, additional retries will be performed.
|
|
102
|
+
# @see Elasticsearch::API::Actions#update for more info about the
|
|
103
|
+
# arguments and the return value.
|
|
104
|
+
def update(**args)
|
|
105
|
+
retry_request { transport_client.update(**args) }
|
|
106
|
+
end
|
|
99
107
|
end
|
|
100
108
|
end
|
|
101
109
|
end
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'active_support'
|
|
4
|
+
require 'active_support/core_ext/object/blank'
|
|
5
|
+
|
|
3
6
|
require_relative 'indexable'
|
|
4
7
|
require_relative 'indices/settings'
|
|
5
8
|
require_relative 'errors/writable_index_error'
|
|
@@ -52,6 +55,46 @@ module JayAPI
|
|
|
52
55
|
super.first
|
|
53
56
|
end
|
|
54
57
|
|
|
58
|
+
# Updates a document by ID.
|
|
59
|
+
# @param [String] id The ID of the document to update.
|
|
60
|
+
# @param [Hash, nil] doc The partial document to update the existing
|
|
61
|
+
# document with. If +nil+ is given, the +script+ parameter must be
|
|
62
|
+
# provided. If both +doc+ and +script+ are given, the +doc+ parameter
|
|
63
|
+
# will be ignored by Elasticsearch.
|
|
64
|
+
# @param [JayAPI::Elasticsearch::Script, Hash, nil] script The script to
|
|
65
|
+
# update the existing document with. If +nil+ is given, the +doc+
|
|
66
|
+
# parameter must be provided. It's recommended to use a
|
|
67
|
+
# +JayAPI::Elasticsearch::Script+ object, but a Hash can also be used.
|
|
68
|
+
# @return [Hash] A Hash containing information about the updated document.
|
|
69
|
+
# An example of such Hash is:
|
|
70
|
+
#
|
|
71
|
+
# {
|
|
72
|
+
# "_index" : "xyz01_build_properties",
|
|
73
|
+
# "_type" : "_doc",
|
|
74
|
+
# "_id" : "ns4AAZ8BXEjZhYMmw-8y",
|
|
75
|
+
# "_version" : 7,
|
|
76
|
+
# "result" : "updated",
|
|
77
|
+
# "_shards" : {
|
|
78
|
+
# "total" : 2,
|
|
79
|
+
# "successful" : 2,
|
|
80
|
+
# "failed" : 0
|
|
81
|
+
# },
|
|
82
|
+
# "_seq_no" : 11,
|
|
83
|
+
# "_primary_term" : 1
|
|
84
|
+
# }
|
|
85
|
+
#
|
|
86
|
+
# For information on how to use the script and about the contents of the
|
|
87
|
+
# returned Hash please see:
|
|
88
|
+
# https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-update
|
|
89
|
+
# @raise [ArgumentError] If both +doc+ and +script+ are +nil+.
|
|
90
|
+
# @raise [Elasticsearch::Transport::Transport::ServerError] If the
|
|
91
|
+
# update fails.
|
|
92
|
+
def update(id:, doc: nil, script: nil)
|
|
93
|
+
raise ArgumentError, "Either 'doc' or 'script' must be provided" if doc.blank? && script.blank?
|
|
94
|
+
|
|
95
|
+
client.update(index: index_name, id:, body: { doc: doc, script: script&.to_h }.compact)
|
|
96
|
+
end
|
|
97
|
+
|
|
55
98
|
# @return [JayAPI::Elasticsearch::Indices::Settings] The settings for the
|
|
56
99
|
# index.
|
|
57
100
|
def settings
|
|
@@ -19,8 +19,8 @@ module JayAPI
|
|
|
19
19
|
# The keys are the names of the script variables, the values the
|
|
20
20
|
# paths to the metrics (relative to the parent aggregation).
|
|
21
21
|
# The script will receive these variables in its +params+.
|
|
22
|
-
# @param [JayAPI::Elasticsearch::
|
|
23
|
-
#
|
|
22
|
+
# @param [JayAPI::Elasticsearch::Script] script Script used to decide
|
|
23
|
+
# whether to keep each bucket.
|
|
24
24
|
# @param [String, nil] gap_policy Optional gap policy (e.g. "skip",
|
|
25
25
|
# "insert_zeros").
|
|
26
26
|
def initialize(name, buckets_path:, script:, gap_policy: nil)
|
|
@@ -19,10 +19,9 @@ module JayAPI
|
|
|
19
19
|
# @param [String] name The name used by Elasticsearch to identify each
|
|
20
20
|
# of the aggregations.
|
|
21
21
|
# @param [String] field The field whose unique values should be counted.
|
|
22
|
-
# @param [JayAPI::Elasticsearch::
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
# field.
|
|
22
|
+
# @param [JayAPI::Elasticsearch::Script] script If a script is given
|
|
23
|
+
# the aggregation will count the unique values returned by the
|
|
24
|
+
# script instead of the unique values in a specific field.
|
|
26
25
|
# @param [Integer] size By default the aggregation returns the top 10
|
|
27
26
|
# unique values (the ones with the higher frequency). By specifying
|
|
28
27
|
# a size this can be changed.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'query_clause'
|
|
4
|
+
|
|
5
|
+
module JayAPI
|
|
6
|
+
module Elasticsearch
|
|
7
|
+
class QueryBuilder
|
|
8
|
+
class QueryClauses
|
|
9
|
+
# Represents an IDs query in Elasticsearch.
|
|
10
|
+
# Information about this type of query can be found here:
|
|
11
|
+
# https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-ids-query
|
|
12
|
+
class IDs < ::JayAPI::Elasticsearch::QueryBuilder::QueryClauses::QueryClause
|
|
13
|
+
attr_reader :ids
|
|
14
|
+
|
|
15
|
+
# @param [Array<String>] ids The ids of the documents to match.
|
|
16
|
+
def initialize(ids:)
|
|
17
|
+
super()
|
|
18
|
+
|
|
19
|
+
@ids = ids
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @return [Hash] The Hash that represents this query (in
|
|
23
|
+
# Elasticsearch's DSL)
|
|
24
|
+
def to_h
|
|
25
|
+
{
|
|
26
|
+
ids: {
|
|
27
|
+
values: ids
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative 'exists'
|
|
4
|
+
require_relative 'ids'
|
|
4
5
|
require_relative 'match_all'
|
|
5
6
|
require_relative 'match_none'
|
|
6
7
|
require_relative 'match_phrase'
|
|
@@ -116,6 +117,18 @@ module JayAPI
|
|
|
116
117
|
self << ::JayAPI::Elasticsearch::QueryBuilder::QueryClauses::Regexp.new(**params)
|
|
117
118
|
end
|
|
118
119
|
|
|
120
|
+
# Adds a +JayAPI::Elasticsearch::QueryBuilder::QueryClauses::IDs+
|
|
121
|
+
# clause to the Query Clauses set.
|
|
122
|
+
# @param [Hash] params The parameters for the +IDs+ class'
|
|
123
|
+
# constructor.
|
|
124
|
+
# @see JayAPI::Elasticsearch::QueryBuilder::QueryClauses::IDs#initialize
|
|
125
|
+
# @return [self] Returns itself, so that other methods can be chained.
|
|
126
|
+
# @raise [JayAPI::Elasticsearch::QueryBuilder::Errors::QueryBuilderError]
|
|
127
|
+
# If an error occurs when trying to add the query clause to the set.
|
|
128
|
+
def ids(**params)
|
|
129
|
+
self << ::JayAPI::Elasticsearch::QueryBuilder::QueryClauses::IDs.new(**params)
|
|
130
|
+
end
|
|
131
|
+
|
|
119
132
|
# Adds a +JayAPI::Elasticsearch::QueryBuilder::QueryClauses::MatchAll+
|
|
120
133
|
# clause to the Query Clauses set.
|
|
121
134
|
# @return [self] Returns itself, so that other methods can be chained.
|
|
@@ -1,36 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative '../script'
|
|
4
|
+
|
|
3
5
|
module JayAPI
|
|
4
6
|
module Elasticsearch
|
|
5
7
|
class QueryBuilder
|
|
6
8
|
# Represents a scripted element in a query. This scripted element can be
|
|
7
9
|
# used in different places. It can be used in a query clause, but can
|
|
8
10
|
# also be used to create custom aggregations.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# @param [String] source The source for the script element.
|
|
13
|
-
# @param [String] lang The language the script is written in.
|
|
14
|
-
# @param [Hash] params A +Hash+ with key-value pairs for the script's
|
|
15
|
-
# parameters.
|
|
16
|
-
def initialize(source:, lang: 'painless', params: nil)
|
|
17
|
-
@source = source
|
|
18
|
-
@lang = lang
|
|
19
|
-
|
|
20
|
-
# Keeps the parameters from being modified from the outside after the
|
|
21
|
-
# class has been initialized.
|
|
22
|
-
@params = params.dup.freeze
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# @return [Hash] The hash representation of the scripted element.
|
|
26
|
-
def to_h
|
|
27
|
-
{
|
|
28
|
-
source: source,
|
|
29
|
-
lang: lang,
|
|
30
|
-
params: params
|
|
31
|
-
}.compact
|
|
32
|
-
end
|
|
33
|
-
end
|
|
11
|
+
# @deprecated Use +JayAPI::Elasticsearch::Script+ instead.
|
|
12
|
+
Script = JayAPI::Elasticsearch::Script
|
|
34
13
|
end
|
|
35
14
|
end
|
|
36
15
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module JayAPI
|
|
4
|
+
module Elasticsearch
|
|
5
|
+
# Represents a scripted element in Elasticsearch. This scripted element
|
|
6
|
+
# can be used in different places. It can be used in a query clause, but can
|
|
7
|
+
# also be used to create custom aggregations or when updating documents.
|
|
8
|
+
class Script
|
|
9
|
+
attr_reader :source, :lang, :params
|
|
10
|
+
|
|
11
|
+
# @param [String] source The source for the script element.
|
|
12
|
+
# @param [String] lang The language the script is written in.
|
|
13
|
+
# @param [Hash] params A +Hash+ with key-value pairs for the script's
|
|
14
|
+
# parameters.
|
|
15
|
+
def initialize(source:, lang: 'painless', params: nil)
|
|
16
|
+
@source = source
|
|
17
|
+
@lang = lang
|
|
18
|
+
|
|
19
|
+
# Keeps the parameters from being modified from the outside after the
|
|
20
|
+
# class has been initialized.
|
|
21
|
+
@params = params.dup.freeze
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @return [Hash] The hash representation of the scripted element.
|
|
25
|
+
def to_h
|
|
26
|
+
{
|
|
27
|
+
source: source,
|
|
28
|
+
lang: lang,
|
|
29
|
+
params: params
|
|
30
|
+
}.compact
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -13,6 +13,7 @@ require_relative 'elasticsearch/mixins'
|
|
|
13
13
|
require_relative 'elasticsearch/query_builder'
|
|
14
14
|
require_relative 'elasticsearch/query_results'
|
|
15
15
|
require_relative 'elasticsearch/response'
|
|
16
|
+
require_relative 'elasticsearch/script'
|
|
16
17
|
require_relative 'elasticsearch/search_after_results'
|
|
17
18
|
require_relative 'elasticsearch/stats'
|
|
18
19
|
require_relative 'elasticsearch/tasks'
|
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.8.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-
|
|
12
|
+
date: 2026-07-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|
|
@@ -162,6 +162,7 @@ files:
|
|
|
162
162
|
- lib/jay_api/elasticsearch/query_builder/query_clauses.rb
|
|
163
163
|
- lib/jay_api/elasticsearch/query_builder/query_clauses/bool.rb
|
|
164
164
|
- lib/jay_api/elasticsearch/query_builder/query_clauses/exists.rb
|
|
165
|
+
- lib/jay_api/elasticsearch/query_builder/query_clauses/ids.rb
|
|
165
166
|
- lib/jay_api/elasticsearch/query_builder/query_clauses/match_all.rb
|
|
166
167
|
- lib/jay_api/elasticsearch/query_builder/query_clauses/match_clauses.rb
|
|
167
168
|
- lib/jay_api/elasticsearch/query_builder/query_clauses/match_none.rb
|
|
@@ -177,6 +178,7 @@ files:
|
|
|
177
178
|
- lib/jay_api/elasticsearch/query_builder/script.rb
|
|
178
179
|
- lib/jay_api/elasticsearch/query_results.rb
|
|
179
180
|
- lib/jay_api/elasticsearch/response.rb
|
|
181
|
+
- lib/jay_api/elasticsearch/script.rb
|
|
180
182
|
- lib/jay_api/elasticsearch/search_after_results.rb
|
|
181
183
|
- lib/jay_api/elasticsearch/stats.rb
|
|
182
184
|
- lib/jay_api/elasticsearch/stats/errors/stats_data_not_available.rb
|