elastic-enterprise-search 8.2.0 → 8.2.1
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/docs/guide/connecting.asciidoc +0 -1
- data/docs/guide/overview.asciidoc +30 -1
- data/docs/guide/release_notes/80.asciidoc +11 -0
- data/docs/guide/release_notes/81.asciidoc +11 -0
- data/docs/guide/release_notes/82.asciidoc +11 -0
- data/docs/guide/workplace-search-api.asciidoc +24 -4
- data/elastic-enterprise-search.gemspec +1 -1
- data/lib/elastic/enterprise-search/client.rb +13 -1
- data/lib/elastic/enterprise-search/version.rb +1 -1
- data/lib/elastic/workplace-search/workplace_search.rb +9 -2
- data/spec/workplace-search/client_spec.rb +10 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6d66a77dd32e97bc9bb48101c97ee7b96d3ffef54db3779866a7371ab131523
|
4
|
+
data.tar.gz: 3b31e2deec924443691908abef0be3ed985e09282074e1c3fd37ac1b87b3d67f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '060287850883e09c45626b58b282c06d6aa52a177a915636459a452aec11d96ecda0e17bd8ba8c47546543a483761bbadd40ec16da2def6e4bccfcbbc0696cb8'
|
7
|
+
data.tar.gz: 372c2381a0fe668b9fb160b0e0d9eb407607df1f36b49faff209c1a73fa71cc742b0619ccc0f997683e8193f4e15d7f4e60b8b37c3547103d46a46729240da4c
|
@@ -14,6 +14,7 @@ For **Elastic Enterprise Search 7.0** and later, use the major version 7 (`7.x.y
|
|
14
14
|
|
15
15
|
[discrete]
|
16
16
|
=== HTTP Library
|
17
|
+
|
17
18
|
This library uses https://github.com/elastic/elastic-transport-ruby[elastic-transport], the low-level Ruby client for connecting to an Elastic clusters - also used in the official https://github.com/elastic/elasticsearch-ruby[Elasticsearch Ruby Client]. It uses https://rubygems.org/gems/faraday[Faraday], which supports several https://lostisland.github.io/faraday/adapters/[adapters] and will use `Net::HTTP` by default. For optimal performance with the Enterprise Search API, we suggest using an HTTP library which supports persistent ("keep-alive") connections. For the standard Ruby implementation, this could be https://github.com/drbrain/net-http-persistent[Net::HTTP::Persistent], https://github.com/toland/patron[patron] or https://github.com/typhoeus/typhoeus[Typhoeus]. For JRuby, https://github.com/cheald/manticore[Manticore] is a great option as well. Require the library for the adapter in your code and then pass in the `:adapter` parameter to the client when you initialize it:
|
18
19
|
|
19
20
|
[source,ruby]
|
@@ -38,7 +39,7 @@ If you don't specify a host and port, the client will default to `http://localho
|
|
38
39
|
[discrete]
|
39
40
|
=== Logging
|
40
41
|
|
41
|
-
You can enable logging with the default logger by passing `log: true` as a parameter to the client's initializer, or pass in a Logger object with the `:logger` parameter:
|
42
|
+
You can enable logging with the default logger by passing `log: true` as a parameter to the client's initializer, or pass in a Logger object with the `:logger` parameter, any confoming logger implementation:
|
42
43
|
|
43
44
|
[source,rb]
|
44
45
|
----------------------------
|
@@ -46,6 +47,34 @@ logger = MyLogger.new
|
|
46
47
|
client = Elastic::EnterpriseSearch::Client.new(logger: logger)
|
47
48
|
----------------------------
|
48
49
|
|
50
|
+
To trace requests and responses in the _Curl_ format, set the `trace` argument:
|
51
|
+
|
52
|
+
[source,rb]
|
53
|
+
----------------------------
|
54
|
+
> client = Elastic::EnterpriseSearch::Client.new(trace: true)
|
55
|
+
> client.health
|
56
|
+
curl -X GET -H 'x-elastic-client-meta: ent=8.3.0,rb=3.1.2,t=8.0.1,fd=1.10.0,nh=0.2.0, User-Agent: elastic-transport-ruby/8.0.1 (RUBY_VERSION: 3.1.2; linux x86_64; Faraday v1.10.0), Content-Type: application/json
|
57
|
+
' 'http://localhost:9200/api/ent/v1/internal/health/?pretty'
|
58
|
+
|
59
|
+
# 2022-05-23T08:39:09+01:00 [200] (0.049s)
|
60
|
+
#
|
61
|
+
# {"name":"5b8067bf95fb", ...
|
62
|
+
=>
|
63
|
+
#<Elastic::API::Response:0x00007f9096e15f90
|
64
|
+
@response=
|
65
|
+
#<Elastic::Transport::Transport::Response:0x00007f9096e160a8
|
66
|
+
@body=
|
67
|
+
{"name"=>"5b8067bf95fb",
|
68
|
+
...
|
69
|
+
----------------------------
|
70
|
+
|
71
|
+
This will use the `elastic-transport` default logger. But you can pass in a custom logger with:
|
72
|
+
|
73
|
+
[source,rb]
|
74
|
+
----------------------------
|
75
|
+
client = Elastic::EnterpriseSearch::Client.new(tracer: my_tracer)
|
76
|
+
----------------------------
|
77
|
+
|
49
78
|
[discrete]
|
50
79
|
=== License
|
51
80
|
|
@@ -1,4 +1,15 @@
|
|
1
1
|
[[release_notes_80]]
|
2
|
+
=== 8.0 Release notes
|
3
|
+
|
4
|
+
[discrete]
|
5
|
+
[[release_notes_801]]
|
6
|
+
=== 8.0.1 Release notes
|
7
|
+
|
8
|
+
- Adds tracer parameters to enable tracing in elastic-transport. See https://www.elastic.co/guide/en/enterprise-search-clients/ruby/current/overview.html#_logging[logging] for more information.
|
9
|
+
- Updates Workplace Search OAuth implementation. See https://www.elastic.co/guide/en/enterprise-search-clients/ruby/current/workplace-search-api.html#ws-oauth-authentication[OAuth Authentication] for changes in the OAuth process.
|
10
|
+
|
11
|
+
[discrete]
|
12
|
+
[[release_notes_800]]
|
2
13
|
=== 8.0.0 Release notes
|
3
14
|
|
4
15
|
[discrete]
|
@@ -1,4 +1,15 @@
|
|
1
1
|
[[release_notes_81]]
|
2
|
+
=== 8.1 Release notes
|
3
|
+
|
4
|
+
[discrete]
|
5
|
+
[[release_notes_811]]
|
6
|
+
=== 8.1.1 Release notes
|
7
|
+
|
8
|
+
- Adds tracer parameters to enable tracing in elastic-transport. See https://www.elastic.co/guide/en/enterprise-search-clients/ruby/current/overview.html#_logging[logging] for more information.
|
9
|
+
- Updates Workplace Search OAuth implementation. See https://www.elastic.co/guide/en/enterprise-search-clients/ruby/current/workplace-search-api.html#ws-oauth-authentication[OAuth Authentication] for changes in the OAuth process.
|
10
|
+
|
11
|
+
[discrete]
|
12
|
+
[[release_notes_810]]
|
2
13
|
=== 8.1.0 Release notes
|
3
14
|
|
4
15
|
[discrete]
|
@@ -1,4 +1,15 @@
|
|
1
1
|
[[release_notes_82]]
|
2
|
+
=== 8.2 Release notes
|
3
|
+
|
4
|
+
[discrete]
|
5
|
+
[[release_notes_821]]
|
6
|
+
=== 8.2.1 Release notes
|
7
|
+
|
8
|
+
- Adds tracer parameters to enable tracing in elastic-transport. See https://www.elastic.co/guide/en/enterprise-search-clients/ruby/current/overview.html#_logging[logging] for more information.
|
9
|
+
- Updates Workplace Search OAuth implementation. See https://www.elastic.co/guide/en/enterprise-search-clients/ruby/current/workplace-search-api.html#ws-oauth-authentication[OAuth Authentication] for changes in the OAuth process.
|
10
|
+
|
11
|
+
[discrete]
|
12
|
+
[[release_notes_820]]
|
2
13
|
=== 8.2.0 Release notes
|
3
14
|
|
4
15
|
[discrete]
|
@@ -76,22 +76,42 @@ client.delete_documents_by_query(content_source_id, query: query)
|
|
76
76
|
[[ws-oauth-authentication]]
|
77
77
|
=== OAuth Authentication
|
78
78
|
|
79
|
-
You need to configure the OAuth Application for Search in order to use the Workplace Search client's `search` and `create_analytics` endpoints. You need to follow the steps in https://www.elastic.co/guide/en/workplace-search/current/building-custom-search-workplace-search.html#configuring-search-oauth[Configuring the OAuth Application for Search] to retrieve the credentials: Client ID and Client Secret to request access tokens from the authentication server.
|
79
|
+
You need to configure the OAuth Application for Search in order to use the Workplace Search client's `search` and `create_analytics` endpoints. You need to follow the steps in https://www.elastic.co/guide/en/workplace-search/current/building-custom-search-workplace-search.html#configuring-search-oauth[Configuring the OAuth Application for Search] to retrieve the credentials: **Client ID** and **Client Secret** to request access tokens from the authentication server.
|
80
|
+
|
81
|
+
The client implements https://www.elastic.co/guide/en/workplace-search/current/building-custom-search-workplace-search.html#authenticating-search-user-confidential[Authenticating Users with a Confidential OAuth Flow]. It provides a helper to obtain the autorization URL directly from the client once you've set the necessary values.
|
82
|
+
|
83
|
+
The authorization endpoint is hosted by your Kibana deployment, so you need to provide the client with the https://www.elastic.co/guide/en/enterprise-search/current/endpoints-ref.html#kibana-base-url[base URL of your Kibana instance]. You can do this when you initialize the client:
|
84
|
+
|
85
|
+
[source,rb]
|
86
|
+
----------------------------
|
87
|
+
client = Elastic::EnterpriseSearch::WorkplaceSearch::Client.new(http_auth: <access_token>, kibana_url: <kibana_url>)
|
88
|
+
----------------------------
|
89
|
+
|
90
|
+
Or you can set in an existing client:
|
80
91
|
|
81
92
|
[source,rb]
|
82
93
|
----------------------------
|
83
94
|
client = Elastic::EnterpriseSearch::WorkplaceSearch::Client.new(http_auth: <access_token>)
|
95
|
+
client.kibana_url = <kibana_url>
|
96
|
+
----------------------------
|
84
97
|
|
98
|
+
Once you've instantiated a client and the base URL of your Kibana instance is set, you can get the URL for authorization like so:
|
99
|
+
[source,rb]
|
100
|
+
----------------------------
|
101
|
+
# You get the values for client_id and client_secret when configuring the OAuth Application:
|
85
102
|
client_id = <client_id>
|
86
103
|
client_secret = <client_secret>
|
87
104
|
redirect_uri = <redirect_uri>
|
88
105
|
|
89
106
|
# Get the authorization URL:
|
90
107
|
client.authorization_url(client_id, redirect_uri)
|
91
|
-
> https://
|
108
|
+
> https://kibana_url/app/enterprise_search/workplace_search/p/oauth/authorize?response_type=code&client_id=client_id&redirect_uri=https%3A%2F%2Flocalhost%3A3002
|
109
|
+
|
92
110
|
----------------------------
|
93
111
|
|
94
|
-
Open the URL to authorize your application. Successful authorization redirects the user in accordance to the redirect URI provided (and configured for the application).
|
112
|
+
Open the URL to authorize your application. Successful authorization redirects the user in accordance to the redirect URI provided (and configured for the application).
|
113
|
+
|
114
|
+
The application server must now request for an `access_token`, which is generated by Workplace Search using the `oauth/token` endpoint, using the **Client ID** and **Client Secret**.
|
95
115
|
|
96
116
|
[source,rb]
|
97
117
|
----------------------------
|
@@ -100,7 +120,7 @@ authorization_code = '<paste code from redirect>'
|
|
100
120
|
access_token = client.request_access_token(client_id, client_secret, authorization_code, redirect_uri)
|
101
121
|
|
102
122
|
# The access_token can now be used to issue a search request:
|
103
|
-
client.search(body: {query: 'search query'}, access_token: access_token)
|
123
|
+
client.search(body: { query: 'search query' }, access_token: access_token)
|
104
124
|
----------------------------
|
105
125
|
|
106
126
|
See https://www.elastic.co/guide/en/workplace-search/current/workplace-search-search-api.html#search-api-overview[Search API Overview] for more search parameters.
|
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
|
|
47
47
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
48
48
|
s.require_paths = ['lib']
|
49
49
|
|
50
|
-
s.add_dependency 'elastic-transport', '8
|
50
|
+
s.add_dependency 'elastic-transport', '~> 8'
|
51
51
|
s.add_runtime_dependency 'jwt', '>= 1.5', '< 3.0'
|
52
52
|
s.add_development_dependency 'awesome_print'
|
53
53
|
s.add_development_dependency 'byebug' unless defined?(JRUBY_VERSION)
|
@@ -58,6 +58,8 @@ module Elastic
|
|
58
58
|
# @option options [String] :proxy url of proxy to use, ex: "http://localhost:8888"
|
59
59
|
# @option options [Boolean] :log Use the default logger (disabled by default)
|
60
60
|
# @option arguments [Object] :logger An instance of a Logger-compatible object
|
61
|
+
# @option arguments [Boolean] :trace Use the default tracer (disabled by default)
|
62
|
+
# @option arguments [Object] :tracer An instance of a Logger-compatible object
|
61
63
|
# @option arguments [Symbol] :adapter A specific adapter for Faraday (e.g. `:patron`)
|
62
64
|
# @option enable_meta_header [Boolean] :enable_meta_header Enable sending the meta data header to Cloud.
|
63
65
|
# (Default: true)
|
@@ -77,7 +79,9 @@ module Elastic
|
|
77
79
|
transport_options: {
|
78
80
|
request: { open_timeout: open_timeout }
|
79
81
|
},
|
80
|
-
enable_meta_header: @options[:enable_meta_header] || true
|
82
|
+
enable_meta_header: @options[:enable_meta_header] || true,
|
83
|
+
trace: trace,
|
84
|
+
tracer: tracer
|
81
85
|
)
|
82
86
|
end
|
83
87
|
|
@@ -109,6 +113,14 @@ module Elastic
|
|
109
113
|
@options[:adapter]
|
110
114
|
end
|
111
115
|
|
116
|
+
def tracer
|
117
|
+
@options[:tracer]
|
118
|
+
end
|
119
|
+
|
120
|
+
def trace
|
121
|
+
@options[:trace]
|
122
|
+
end
|
123
|
+
|
112
124
|
def host
|
113
125
|
return DEFAULT_HOST unless @options[:host]
|
114
126
|
|
@@ -27,12 +27,17 @@ module Elastic
|
|
27
27
|
include Elastic::EnterpriseSearch::WorkplaceSearch::Actions
|
28
28
|
include Elastic::EnterpriseSearch::Utils
|
29
29
|
|
30
|
+
attr_accessor :kibana_url
|
31
|
+
|
30
32
|
# Create a new Elastic::EnterpriseSearch::WorkplaceSearch::Client client
|
31
33
|
#
|
32
34
|
# @param options [Hash] a hash of configuration options
|
33
35
|
# @option options [String] :access_token the access token for workplace search
|
34
36
|
# @option options [String] :endpoint the endpoint Workplace Search
|
37
|
+
# @option options [String] :kibana_url The base URL of your Kibana instance
|
38
|
+
#
|
35
39
|
def initialize(options = {})
|
40
|
+
@kibana_url = options[:kibana_url]
|
36
41
|
super(options)
|
37
42
|
end
|
38
43
|
|
@@ -45,9 +50,11 @@ module Elastic
|
|
45
50
|
end
|
46
51
|
|
47
52
|
def authorization_url(client_id, redirect_uri)
|
53
|
+
raise ArgumentError, 'kibana_url The base URL of your Kibana instance must be set in the client' unless kibana_url
|
54
|
+
|
48
55
|
[
|
49
|
-
|
50
|
-
'/
|
56
|
+
kibana_url,
|
57
|
+
'/app/enterprise_search/workplace_search/p/oauth/authorize?',
|
51
58
|
'response_type=code&',
|
52
59
|
"client_id=#{client_id}&",
|
53
60
|
"redirect_uri=#{CGI.escape(redirect_uri)}"
|
@@ -91,10 +91,18 @@ describe Elastic::EnterpriseSearch::WorkplaceSearch::Client do
|
|
91
91
|
context 'OAuth' do
|
92
92
|
let(:client) { Elastic::EnterpriseSearch::WorkplaceSearch::Client.new(host: host) }
|
93
93
|
|
94
|
-
it 'generates an authorization url' do
|
95
|
-
|
94
|
+
it 'generates an authorization url when kibana url has been set' do
|
95
|
+
client.kibana_url = 'http://localhost:5601'
|
96
|
+
authorization_url = "#{client.kibana_url}/app/enterprise_search/workplace_search/p/oauth/authorize?" \
|
97
|
+
'response_type=code&client_id=client_id&redirect_uri=https%3A%2F%2Flocalhost%3A3002'
|
96
98
|
expect(client.authorization_url('client_id', 'https://localhost:3002')).to eq authorization_url
|
97
99
|
end
|
100
|
+
|
101
|
+
it 'raises an error when kibana url is not set' do
|
102
|
+
expect do
|
103
|
+
client.authorization_url('client_id', 'https://localhost:3002')
|
104
|
+
end.to raise_exception(ArgumentError)
|
105
|
+
end
|
98
106
|
end
|
99
107
|
|
100
108
|
context 'adapters' do
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic-enterprise-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.2.
|
4
|
+
version: 8.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernando Briano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elastic-transport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 8
|
19
|
+
version: '8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 8
|
26
|
+
version: '8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jwt
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -419,7 +419,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
419
419
|
- !ruby/object:Gem::Version
|
420
420
|
version: '0'
|
421
421
|
requirements: []
|
422
|
-
rubygems_version: 3.3.
|
422
|
+
rubygems_version: 3.3.7
|
423
423
|
signing_key:
|
424
424
|
specification_version: 4
|
425
425
|
summary: Official API client for Elastic Enterprise Search
|