elastic-enterprise-search 8.1.1 → 8.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ci/jobs/{elastic+enterprise-search-ruby+7.15.yml → elastic+enterprise-search-ruby+7.17.yml} +4 -4
- data/.ci/jobs/{elastic+enterprise-search-ruby+7.16.yml → elastic+enterprise-search-ruby+8.0.yml} +4 -4
- data/.ci/run-enterprise-search.sh +1 -0
- data/.ci/test-matrix.yml +1 -1
- data/docs/guide/app-search-api.asciidoc +21 -0
- data/docs/guide/connecting.asciidoc +1 -0
- data/docs/guide/overview.asciidoc +1 -30
- data/docs/guide/release_notes/80.asciidoc +0 -11
- data/docs/guide/release_notes/81.asciidoc +0 -11
- data/docs/guide/release_notes/82.asciidoc +31 -0
- data/docs/guide/release_notes/index.asciidoc +3 -0
- data/docs/guide/workplace-search-api.asciidoc +4 -24
- data/elastic-enterprise-search.gemspec +1 -1
- data/lib/elastic/app-search/api/adaptive_relevance_suggestions.rb +1 -1
- data/lib/elastic/app-search/api/create_curation.rb +1 -1
- data/lib/elastic/app-search/api/list_adaptive_relevance_suggestions.rb +1 -1
- data/lib/elastic/app-search/api/put_adaptive_relevance_settings.rb +1 -1
- data/lib/elastic/app-search/api/put_curation.rb +1 -1
- data/lib/elastic/app-search/api/search_es_search.rb +53 -0
- data/lib/elastic/app-search/api/search_explain.rb +61 -0
- data/lib/elastic/enterprise-search/api/version.rb +1 -1
- data/lib/elastic/enterprise-search/client.rb +1 -13
- data/lib/elastic/enterprise-search/version.rb +1 -1
- data/lib/elastic/workplace-search/workplace_search.rb +2 -9
- data/spec/integration/app-search/elasticsearch_search_spec.rb +63 -0
- data/spec/integration/app-search/explain_search_spec.rb +59 -0
- data/spec/workplace-search/client_spec.rb +2 -10
- metadata +12 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5beefad27301e777c767b0759b154f6e0bba47db65e0e02cacd206f4ff2c2696
|
4
|
+
data.tar.gz: 86610a1a51529bf54c454e93f2977a1968887e3737e1bfd2ef058b255a1b1975
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0e0e3f3bcf5994ea89f6dc399527c1a02b5b2699ed3af62fedf9d7bf62b32d2c475b104988190b7be5f1d1368ed73241f53392c6934663a76425648bfadf5f7
|
7
|
+
data.tar.gz: 691d3a79357db4880f777fd4a6975c9a434ade303037d7a94523d82e67266c553d7fded40e7f883b6e283d438b7a66d8d8dce7a72a48c4387c65b746c359aa4b
|
data/.ci/jobs/{elastic+enterprise-search-ruby+7.15.yml → elastic+enterprise-search-ruby+7.17.yml}
RENAMED
@@ -1,12 +1,12 @@
|
|
1
1
|
---
|
2
2
|
- job:
|
3
|
-
name: elastic+enterprise-search-ruby+7.
|
4
|
-
display-name: 'elastic / enterprise-search-ruby # 7.
|
5
|
-
description: Testing the enterprise-search-ruby 7.
|
3
|
+
name: elastic+enterprise-search-ruby+7.17
|
4
|
+
display-name: 'elastic / enterprise-search-ruby # 7.17'
|
5
|
+
description: Testing the enterprise-search-ruby 7.17 branch.
|
6
6
|
junit_results: "*-junit.xml"
|
7
7
|
parameters:
|
8
8
|
- string:
|
9
9
|
name: branch_specifier
|
10
|
-
default: refs/heads/7.
|
10
|
+
default: refs/heads/7.17
|
11
11
|
description: the Git branch specifier to build (<branchName>, <tagName>,
|
12
12
|
<commitId>, etc.)
|
data/.ci/jobs/{elastic+enterprise-search-ruby+7.16.yml → elastic+enterprise-search-ruby+8.0.yml}
RENAMED
@@ -1,12 +1,12 @@
|
|
1
1
|
---
|
2
2
|
- job:
|
3
|
-
name: elastic+enterprise-search-ruby+
|
4
|
-
display-name: 'elastic / enterprise-search-ruby #
|
5
|
-
description: Testing the enterprise-search-ruby
|
3
|
+
name: elastic+enterprise-search-ruby+8.0
|
4
|
+
display-name: 'elastic / enterprise-search-ruby # 8.0'
|
5
|
+
description: Testing the enterprise-search-ruby 8.0 branch.
|
6
6
|
junit_results: "*-junit.xml"
|
7
7
|
parameters:
|
8
8
|
- string:
|
9
9
|
name: branch_specifier
|
10
|
-
default: refs/heads/
|
10
|
+
default: refs/heads/8.0
|
11
11
|
description: the Git branch specifier to build (<branchName>, <tagName>,
|
12
12
|
<commitId>, etc.)
|
@@ -54,6 +54,7 @@ docker run \
|
|
54
54
|
--env "elasticsearch.ssl.certificate=/usr/share/app-search/config/certs/testnode.crt" \
|
55
55
|
--env "elasticsearch.ssl.certificate_authority=/usr/share/app-search/config/certs/ca.crt" \
|
56
56
|
--env "elasticsearch.ssl.key=/usr/share/app-search/config/certs/testnode.key" \
|
57
|
+
--env "ELASTICSEARCH_SEARCH_API=true" \
|
57
58
|
--volume $ssl_cert:/usr/share/app-search/config/certs/testnode.crt \
|
58
59
|
--volume $ssl_key:/usr/share/app-search/config/certs/testnode.key \
|
59
60
|
--volume $ssl_ca:/usr/share/app-search/config/certs/ca.crt \
|
data/.ci/test-matrix.yml
CHANGED
@@ -336,6 +336,27 @@ client.put_adaptive_relevance_settings(engine_name, body: body)
|
|
336
336
|
client.refresh_adaptive_relevance_update_process(engine_name, adaptive_relevance_suggestion_type: 'curation')
|
337
337
|
----------------------------
|
338
338
|
|
339
|
+
=== Elasticsearch Search
|
340
|
+
|
341
|
+
Utilize the API to passthrough and execute raw Elasticsearch queries against the indices that power Enterprise Search engines.
|
342
|
+
|
343
|
+
[source,rb]
|
344
|
+
----------------------------
|
345
|
+
es_request = { body: { query: { bool: { must: { term: { title: 'test' } } } } } }
|
346
|
+
client.search_es_search(engine_name, body: { request: es_request })
|
347
|
+
----------------------------
|
348
|
+
|
349
|
+
=== Search Explain
|
350
|
+
|
351
|
+
Submit a search and retrieve an Elasticsearch query.
|
352
|
+
|
353
|
+
[source,rb]
|
354
|
+
----------------------------
|
355
|
+
response = client.search_explain(engine_name, body: { query: 'test' })
|
356
|
+
response.body['query_string']
|
357
|
+
# => "GET enterprise-search-engine-app-search-explain/_search"
|
358
|
+
----------------------------
|
359
|
+
|
339
360
|
=== Other API Endpoints
|
340
361
|
|
341
362
|
[source,rb]
|
@@ -14,7 +14,6 @@ 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
|
-
|
18
17
|
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:
|
19
18
|
|
20
19
|
[source,ruby]
|
@@ -39,7 +38,7 @@ If you don't specify a host and port, the client will default to `http://localho
|
|
39
38
|
[discrete]
|
40
39
|
=== Logging
|
41
40
|
|
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
|
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:
|
43
42
|
|
44
43
|
[source,rb]
|
45
44
|
----------------------------
|
@@ -47,34 +46,6 @@ logger = MyLogger.new
|
|
47
46
|
client = Elastic::EnterpriseSearch::Client.new(logger: logger)
|
48
47
|
----------------------------
|
49
48
|
|
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
|
-
|
78
49
|
[discrete]
|
79
50
|
=== License
|
80
51
|
|
@@ -1,15 +1,4 @@
|
|
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]]
|
13
2
|
=== 8.0.0 Release notes
|
14
3
|
|
15
4
|
[discrete]
|
@@ -1,15 +1,4 @@
|
|
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]]
|
13
2
|
=== 8.1.0 Release notes
|
14
3
|
|
15
4
|
[discrete]
|
@@ -0,0 +1,31 @@
|
|
1
|
+
[[release_notes_82]]
|
2
|
+
=== 8.2.0 Release notes
|
3
|
+
|
4
|
+
[discrete]
|
5
|
+
==== General
|
6
|
+
|
7
|
+
- Tested with Elastic Enterprise Search API version 8.2.0.
|
8
|
+
- Tested with Ruby 2.7, 3.0, 3.1, JRuby 9.3. Older versions of Ruby have reached end of life and been removed from the testing matrices. Minimum required Ruby version is Ruby 2.6 to keep compatibility with JRuby 9.3, but it may be upgraded to 2.7 once JRuby 9.4 comes out.
|
9
|
+
|
10
|
+
[discrete]
|
11
|
+
==== App Search
|
12
|
+
[discrete]
|
13
|
+
==== New APIs
|
14
|
+
|
15
|
+
* Adds Elasticsearch Search API (In Technical Preview): Utilize the API to passthrough and execute raw Elasticsearch queries against the indices that power Enterprise Search engines.
|
16
|
+
|
17
|
+
+
|
18
|
+
[source,rb]
|
19
|
+
----------------------------
|
20
|
+
es_request = { body: { query: { bool: { must: { term: { title: 'test' } } } } } }
|
21
|
+
client.search_es_search(engine_name, body: { request: es_request })
|
22
|
+
----------------------------
|
23
|
+
|
24
|
+
* Adds Search Explain API: Submit a search and retrieve an Elasticsearch query.
|
25
|
+
+
|
26
|
+
[source,rb]
|
27
|
+
----------------------------
|
28
|
+
response = client.search_explain(engine_name, body: { query: 'test' })
|
29
|
+
response.body['query_string']
|
30
|
+
# => "GET enterprise-search-engine-app-search-explain/_search"
|
31
|
+
----------------------------
|
@@ -3,6 +3,8 @@
|
|
3
3
|
|
4
4
|
[discrete]
|
5
5
|
=== 8.x
|
6
|
+
|
7
|
+
* <<release_notes_82, 8.2.0 Release Notes>>
|
6
8
|
* <<release_notes_81, 8.1.0 Release Notes>>
|
7
9
|
* <<release_notes_80, 8.0.0 Release Notes>>
|
8
10
|
|
@@ -18,6 +20,7 @@
|
|
18
20
|
* <<release_notes_711, 7.11.0 Release Notes>>
|
19
21
|
* <<release_notes_710, 7.10.0.beta.1 Release Notes>>
|
20
22
|
|
23
|
+
include::82.asciidoc[]
|
21
24
|
include::81.asciidoc[]
|
22
25
|
include::80.asciidoc[]
|
23
26
|
include::717.asciidoc[]
|
@@ -76,42 +76,22 @@ 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:
|
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:
|
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.
|
91
80
|
|
92
81
|
[source,rb]
|
93
82
|
----------------------------
|
94
83
|
client = Elastic::EnterpriseSearch::WorkplaceSearch::Client.new(http_auth: <access_token>)
|
95
|
-
client.kibana_url = <kibana_url>
|
96
|
-
----------------------------
|
97
84
|
|
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:
|
102
85
|
client_id = <client_id>
|
103
86
|
client_secret = <client_secret>
|
104
87
|
redirect_uri = <redirect_uri>
|
105
88
|
|
106
89
|
# Get the authorization URL:
|
107
90
|
client.authorization_url(client_id, redirect_uri)
|
108
|
-
> https://
|
109
|
-
|
91
|
+
> https://host:port/ws/oauth/authorize?response_type=code&client_id=client_id&redirect_uri=https%3A%2F%2Flocalhost%3A3002
|
110
92
|
----------------------------
|
111
93
|
|
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**.
|
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). 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.
|
115
95
|
|
116
96
|
[source,rb]
|
117
97
|
----------------------------
|
@@ -120,7 +100,7 @@ authorization_code = '<paste code from redirect>'
|
|
120
100
|
access_token = client.request_access_token(client_id, client_secret, authorization_code, redirect_uri)
|
121
101
|
|
122
102
|
# The access_token can now be used to issue a search request:
|
123
|
-
client.search(body: {
|
103
|
+
client.search(body: {query: 'search query'}, access_token: access_token)
|
124
104
|
----------------------------
|
125
105
|
|
126
106
|
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.0.0.pre.
|
50
|
+
s.add_dependency 'elastic-transport', '8.0.0.pre.3'
|
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)
|
@@ -29,7 +29,7 @@ module Elastic
|
|
29
29
|
# @option arguments [String] :search_suggestion_query Query to obtain suggestions (*Required*)
|
30
30
|
# @option arguments [Hash] :body
|
31
31
|
# @option body :page
|
32
|
-
# @option body [
|
32
|
+
# @option body [Hash] :filters
|
33
33
|
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
34
34
|
#
|
35
35
|
# @see https://www.elastic.co/guide/en/app-search/current/adaptive-relevance-api-reference.html#adaptive-relevance-api-get-engine-adaptive-relevance-suggestions-query
|
@@ -31,7 +31,7 @@ module Elastic
|
|
31
31
|
# @option body [Array<string>] :queries List of affected search queries
|
32
32
|
# @option body [Array<string>] :promoted List of promoted document IDs
|
33
33
|
# @option body [Array<string>] :hidden List of hidden document IDs
|
34
|
-
# @option body
|
34
|
+
# @option body :suggestion
|
35
35
|
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
36
36
|
#
|
37
37
|
# @see https://www.elastic.co/guide/en/app-search/current/curations.html#curations-create
|
@@ -28,7 +28,7 @@ module Elastic
|
|
28
28
|
# @param [Hash] arguments endpoint arguments
|
29
29
|
# @option arguments [Hash] :body
|
30
30
|
# @option body :page
|
31
|
-
# @option body [
|
31
|
+
# @option body [Hash] :filters
|
32
32
|
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
33
33
|
#
|
34
34
|
# @see https://www.elastic.co/guide/en/app-search/current/adaptive-relevance-api-reference.html#adaptive-relevance-api-get-engine-adaptive-relevance-suggestions
|
@@ -27,7 +27,7 @@ module Elastic
|
|
27
27
|
# @param [String] engine_name Name of the engine (*Required*)
|
28
28
|
# @param [Hash] arguments endpoint arguments
|
29
29
|
# @option arguments [Hash] :body (Required: curation)
|
30
|
-
# @option body [Hash] :curation
|
30
|
+
# @option body [Hash] :curation
|
31
31
|
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
32
32
|
#
|
33
33
|
# @see https://www.elastic.co/guide/en/app-search/current/adaptive-relevance-api-reference.html#adaptive-relevance-api-put-engine-adaptive-relevance-settings
|
@@ -32,7 +32,7 @@ module Elastic
|
|
32
32
|
# @option body [Array<string>] :queries List of affected search queries
|
33
33
|
# @option body [Array<string>] :promoted List of promoted document IDs
|
34
34
|
# @option body [Array<string>] :hidden List of hidden document IDs
|
35
|
-
# @option body
|
35
|
+
# @option body :suggestion
|
36
36
|
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
37
37
|
#
|
38
38
|
# @see https://www.elastic.co/guide/en/app-search/current/curations.html#curations-update
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with
|
5
|
+
# this work for additional information regarding copyright
|
6
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
7
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
8
|
+
# not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Elastic
|
21
|
+
module EnterpriseSearch
|
22
|
+
module AppSearch
|
23
|
+
module Actions
|
24
|
+
# ElasticsearchSearch - Run a search
|
25
|
+
# Execute the provided Elasticsearch search query against an App Search Engine
|
26
|
+
#
|
27
|
+
# @param [String] engine_name Name of the engine (*Required*)
|
28
|
+
# @param [Hash] arguments endpoint arguments
|
29
|
+
# @option arguments [Hash] :body (Required: request)
|
30
|
+
# @option body :request
|
31
|
+
# @option body :analytics
|
32
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
33
|
+
#
|
34
|
+
# @see https://www.elastic.co/guide/en/app-search/current/elasticsearch-search-api-reference.html
|
35
|
+
#
|
36
|
+
def search_es_search(engine_name, arguments = {})
|
37
|
+
raise ArgumentError, "Required parameter 'engine_name' missing" unless engine_name
|
38
|
+
raise ArgumentError, "Required parameter 'body (request)' missing" unless arguments[:body]
|
39
|
+
|
40
|
+
body = arguments.delete(:body) || {}
|
41
|
+
headers = arguments.delete(:headers) || {}
|
42
|
+
request(
|
43
|
+
:post,
|
44
|
+
"api/as/v0/engines/#{engine_name}/elasticsearch/_search/",
|
45
|
+
arguments,
|
46
|
+
body,
|
47
|
+
headers
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with
|
5
|
+
# this work for additional information regarding copyright
|
6
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
7
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
8
|
+
# not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Elastic
|
21
|
+
module EnterpriseSearch
|
22
|
+
module AppSearch
|
23
|
+
module Actions
|
24
|
+
# SearchExplain - Retrieve the search query
|
25
|
+
# Submit a search and retrieve an Elasticsearch query
|
26
|
+
#
|
27
|
+
# @param [String] engine_name Name of the engine (*Required*)
|
28
|
+
# @param [Hash] arguments endpoint arguments
|
29
|
+
# @option arguments [Hash] :body (Required: query)
|
30
|
+
# @option body [string] :query
|
31
|
+
# @option body :analytics
|
32
|
+
# @option body :boost
|
33
|
+
# @option body :facets
|
34
|
+
# @option body :filters
|
35
|
+
# @option body :group
|
36
|
+
# @option body :page
|
37
|
+
# @option body :result_fields
|
38
|
+
# @option body :search_fields
|
39
|
+
# @option body :sort
|
40
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
41
|
+
#
|
42
|
+
# @see https://www.elastic.co/guide/en/app-search/current/search-explain.html
|
43
|
+
#
|
44
|
+
def search_explain(engine_name, arguments = {})
|
45
|
+
raise ArgumentError, "Required parameter 'engine_name' missing" unless engine_name
|
46
|
+
raise ArgumentError, "Required parameter 'body (query)' missing" unless arguments[:body]
|
47
|
+
|
48
|
+
body = arguments.delete(:body) || {}
|
49
|
+
headers = arguments.delete(:headers) || {}
|
50
|
+
request(
|
51
|
+
:post,
|
52
|
+
"api/as/v0/engines/#{engine_name}/search_explain/",
|
53
|
+
arguments,
|
54
|
+
body,
|
55
|
+
headers
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -26,7 +26,7 @@ module Elastic
|
|
26
26
|
# @param [Hash] arguments endpoint arguments
|
27
27
|
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
28
28
|
#
|
29
|
-
# @see https://www.elastic.co/guide/en/enterprise-search/current/
|
29
|
+
# @see https://www.elastic.co/guide/en/enterprise-search/current/monitoring-apis.html#monitoring-apis-version-api
|
30
30
|
#
|
31
31
|
def version(arguments = {})
|
32
32
|
headers = arguments.delete(:headers) || {}
|
@@ -58,8 +58,6 @@ 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
|
63
61
|
# @option arguments [Symbol] :adapter A specific adapter for Faraday (e.g. `:patron`)
|
64
62
|
# @option enable_meta_header [Boolean] :enable_meta_header Enable sending the meta data header to Cloud.
|
65
63
|
# (Default: true)
|
@@ -79,9 +77,7 @@ module Elastic
|
|
79
77
|
transport_options: {
|
80
78
|
request: { open_timeout: open_timeout }
|
81
79
|
},
|
82
|
-
enable_meta_header: @options[:enable_meta_header] || true
|
83
|
-
trace: trace,
|
84
|
-
tracer: tracer
|
80
|
+
enable_meta_header: @options[:enable_meta_header] || true
|
85
81
|
)
|
86
82
|
end
|
87
83
|
|
@@ -113,14 +109,6 @@ module Elastic
|
|
113
109
|
@options[:adapter]
|
114
110
|
end
|
115
111
|
|
116
|
-
def tracer
|
117
|
-
@options[:tracer]
|
118
|
-
end
|
119
|
-
|
120
|
-
def trace
|
121
|
-
@options[:trace]
|
122
|
-
end
|
123
|
-
|
124
112
|
def host
|
125
113
|
return DEFAULT_HOST unless @options[:host]
|
126
114
|
|
@@ -27,17 +27,12 @@ module Elastic
|
|
27
27
|
include Elastic::EnterpriseSearch::WorkplaceSearch::Actions
|
28
28
|
include Elastic::EnterpriseSearch::Utils
|
29
29
|
|
30
|
-
attr_accessor :kibana_url
|
31
|
-
|
32
30
|
# Create a new Elastic::EnterpriseSearch::WorkplaceSearch::Client client
|
33
31
|
#
|
34
32
|
# @param options [Hash] a hash of configuration options
|
35
33
|
# @option options [String] :access_token the access token for workplace search
|
36
34
|
# @option options [String] :endpoint the endpoint Workplace Search
|
37
|
-
# @option options [String] :kibana_url The base URL of your Kibana instance
|
38
|
-
#
|
39
35
|
def initialize(options = {})
|
40
|
-
@kibana_url = options[:kibana_url]
|
41
36
|
super(options)
|
42
37
|
end
|
43
38
|
|
@@ -50,11 +45,9 @@ module Elastic
|
|
50
45
|
end
|
51
46
|
|
52
47
|
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
|
-
|
55
48
|
[
|
56
|
-
|
57
|
-
'/
|
49
|
+
host,
|
50
|
+
'/ws/oauth/authorize?',
|
58
51
|
'response_type=code&',
|
59
52
|
"client_id=#{client_id}&",
|
60
53
|
"redirect_uri=#{CGI.escape(redirect_uri)}"
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
# frozen_string_literal: true
|
19
|
+
|
20
|
+
require_relative "#{__dir__}/app_search_helper.rb"
|
21
|
+
|
22
|
+
describe Elastic::EnterpriseSearch::AppSearch::Client do
|
23
|
+
context 'Elasticsearch Search' do
|
24
|
+
let(:engine_name) { 'elasticsearch-books' }
|
25
|
+
let(:documents) do
|
26
|
+
[
|
27
|
+
{ title: 'Beasts Before Us', author: 'Elsa Panciroli' },
|
28
|
+
{ title: 'The Rise and Fall of the Dinosaurs', author: 'Steve Brusatte' },
|
29
|
+
{ title: 'Raptor Red', author: 'Robert T. Bakker' },
|
30
|
+
{ title: 'The Earth: A biography of life', author: 'Dr. Elsa Panciroli' }
|
31
|
+
]
|
32
|
+
end
|
33
|
+
let(:api_key_name) { 'my-api-key' }
|
34
|
+
|
35
|
+
before do
|
36
|
+
# Use API Key in client, save a backup to restore original auth:
|
37
|
+
@old_client = @client.dup
|
38
|
+
api_key_body = { name: api_key_name, type: 'private', read: true, write: true, access_all_engines: true }
|
39
|
+
response = client.create_api_key(body: api_key_body)
|
40
|
+
@client.http_auth = response.body['key']
|
41
|
+
create_engine(engine_name)
|
42
|
+
client.index_documents(engine_name, documents: documents)
|
43
|
+
sleep 1
|
44
|
+
end
|
45
|
+
|
46
|
+
after do
|
47
|
+
# Restore original client:
|
48
|
+
@client = @old_client
|
49
|
+
delete_engines
|
50
|
+
client.delete_api_key(api_key_name: api_key_name)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'performs an ES search' do
|
54
|
+
es_request = { body: { query: { bool: { must: { term: { author: 'panciroli' } } } } } }
|
55
|
+
response = client.search_es_search(engine_name, body: { request: es_request })
|
56
|
+
expect(response.status).to eq 200
|
57
|
+
expect(response.body['hits']['hits'].count).to eq 2
|
58
|
+
expect do
|
59
|
+
response.body['hits']['hits'].map { |a| a['_source']['author'] } == ['Elsa Panciroli', 'Dr. Elsa Panciroli']
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
# frozen_string_literal: true
|
19
|
+
|
20
|
+
require_relative "#{__dir__}/app_search_helper.rb"
|
21
|
+
|
22
|
+
describe Elastic::EnterpriseSearch::AppSearch::Client do
|
23
|
+
context 'Elasticsearch Search' do
|
24
|
+
let(:engine_name) { 'app-search-explain' }
|
25
|
+
let(:documents) do
|
26
|
+
[
|
27
|
+
{ title: 'Beasts Before Us', author: 'Elsa Panciroli' },
|
28
|
+
{ title: 'The Rise and Fall of the Dinosaurs', author: 'Steve Brusatte' },
|
29
|
+
{ title: 'Raptor Red', author: 'Robert T. Bakker' },
|
30
|
+
{ title: 'The Earth: A biography of life', author: 'Dr. Elsa Panciroli' }
|
31
|
+
]
|
32
|
+
end
|
33
|
+
let(:api_key_name) { 'my-api-key' }
|
34
|
+
|
35
|
+
before do
|
36
|
+
# Use API Key in client, save a backup to restore original auth:
|
37
|
+
@old_client = @client.dup
|
38
|
+
api_key_body = { name: api_key_name, type: 'private', read: true, write: true, access_all_engines: true }
|
39
|
+
response = client.create_api_key(body: api_key_body)
|
40
|
+
@client.http_auth = response.body['key']
|
41
|
+
create_engine(engine_name)
|
42
|
+
client.index_documents(engine_name, documents: documents)
|
43
|
+
sleep 1
|
44
|
+
end
|
45
|
+
|
46
|
+
after do
|
47
|
+
# Restore original client:
|
48
|
+
@client = @old_client
|
49
|
+
delete_engines
|
50
|
+
client.delete_api_key(api_key_name: api_key_name)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'explains a Search query' do
|
54
|
+
response = client.search_explain(engine_name, body: { query: 'Raptor Red' })
|
55
|
+
expect(response.status).to eq 200
|
56
|
+
expect(response.body['query_string']).to eq 'GET enterprise-search-engine-app-search-explain/_search'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -91,18 +91,10 @@ 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
|
95
|
-
|
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'
|
94
|
+
it 'generates an authorization url' do
|
95
|
+
authorization_url = 'http://localhost:3002/ws/oauth/authorize?response_type=code&client_id=client_id&redirect_uri=https%3A%2F%2Flocalhost%3A3002'
|
98
96
|
expect(client.authorization_url('client_id', 'https://localhost:3002')).to eq authorization_url
|
99
97
|
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
|
106
98
|
end
|
107
99
|
|
108
100
|
context 'adapters' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic-enterprise-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.2.0
|
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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elastic-transport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 8.0.0.pre.
|
19
|
+
version: 8.0.0.pre.3
|
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.0.0.pre.
|
26
|
+
version: 8.0.0.pre.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jwt
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,8 +164,8 @@ files:
|
|
164
164
|
- ".ci/functions/imports.sh"
|
165
165
|
- ".ci/functions/wait-for-container.sh"
|
166
166
|
- ".ci/jobs/defaults.yml"
|
167
|
-
- ".ci/jobs/elastic+enterprise-search-ruby+7.
|
168
|
-
- ".ci/jobs/elastic+enterprise-search-ruby+
|
167
|
+
- ".ci/jobs/elastic+enterprise-search-ruby+7.17.yml"
|
168
|
+
- ".ci/jobs/elastic+enterprise-search-ruby+8.0.yml"
|
169
169
|
- ".ci/jobs/elastic+enterprise-search-ruby+main.yml"
|
170
170
|
- ".ci/jobs/elastic+enterprise-search-ruby+pull-request.yml"
|
171
171
|
- ".ci/make.sh"
|
@@ -207,6 +207,7 @@ files:
|
|
207
207
|
- docs/guide/release_notes/717.asciidoc
|
208
208
|
- docs/guide/release_notes/80.asciidoc
|
209
209
|
- docs/guide/release_notes/81.asciidoc
|
210
|
+
- docs/guide/release_notes/82.asciidoc
|
210
211
|
- docs/guide/release_notes/index.asciidoc
|
211
212
|
- docs/guide/workplace-search-api.asciidoc
|
212
213
|
- elastic-enterprise-search.gemspec
|
@@ -290,6 +291,8 @@ files:
|
|
290
291
|
- lib/elastic/app-search/api/reset_search_settings.rb
|
291
292
|
- lib/elastic/app-search/api/schema.rb
|
292
293
|
- lib/elastic/app-search/api/search.rb
|
294
|
+
- lib/elastic/app-search/api/search_es_search.rb
|
295
|
+
- lib/elastic/app-search/api/search_explain.rb
|
293
296
|
- lib/elastic/app-search/api/search_settings.rb
|
294
297
|
- lib/elastic/app-search/api/synonym_set.rb
|
295
298
|
- lib/elastic/app-search/api/top_clicks_analytics.rb
|
@@ -366,7 +369,9 @@ files:
|
|
366
369
|
- spec/integration/app-search/crawler_user_agent_spec.rb
|
367
370
|
- spec/integration/app-search/curations_spec.rb
|
368
371
|
- spec/integration/app-search/documents_spec.rb
|
372
|
+
- spec/integration/app-search/elasticsearch_search_spec.rb
|
369
373
|
- spec/integration/app-search/engines_spec.rb
|
374
|
+
- spec/integration/app-search/explain_search_spec.rb
|
370
375
|
- spec/integration/app-search/log_clickthrough_spec.rb
|
371
376
|
- spec/integration/app-search/meta_engines_spec.rb
|
372
377
|
- spec/integration/app-search/query_suggestion_spec.rb
|
@@ -414,7 +419,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
414
419
|
- !ruby/object:Gem::Version
|
415
420
|
version: '0'
|
416
421
|
requirements: []
|
417
|
-
rubygems_version: 3.3.
|
422
|
+
rubygems_version: 3.3.3
|
418
423
|
signing_key:
|
419
424
|
specification_version: 4
|
420
425
|
summary: Official API client for Elastic Enterprise Search
|