elastic-enterprise-search 7.10.0.beta.1 → 7.11.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.10.0.beta.1.yml +12 -0
- data/.ci/test-matrix.yml +2 -1
- data/.github/workflows/testing.yml +1 -1
- data/.gitignore +1 -0
- data/CONTRIBUTING.md +43 -0
- data/Gemfile +1 -0
- data/README.md +7 -225
- data/Rakefile +1 -24
- data/docs/guide/app-search-api.asciidoc +172 -0
- data/docs/guide/connecting.asciidoc +125 -0
- data/docs/guide/development.asciidoc +42 -0
- data/docs/guide/enterprise-search-api.asciidoc +46 -0
- data/docs/guide/index.asciidoc +17 -0
- data/docs/guide/installation.asciidoc +18 -0
- data/docs/guide/overview.asciidoc +59 -0
- data/docs/guide/workplace-search-api.asciidoc +121 -0
- data/elastic-enterprise-search.gemspec +5 -4
- data/lib/elastic/app-search/api/add_meta_engine_source.rb +7 -4
- data/lib/elastic/app-search/api/api_logs.rb +15 -16
- data/lib/elastic/app-search/api/count_analytics.rb +7 -5
- data/lib/elastic/app-search/api/create_curation.rb +8 -6
- data/lib/elastic/app-search/api/create_engine.rb +9 -7
- data/lib/elastic/app-search/api/create_synonym_set.rb +6 -5
- data/lib/elastic/app-search/api/curation.rb +6 -5
- data/lib/elastic/app-search/api/delete_curation.rb +6 -5
- data/lib/elastic/app-search/api/delete_documents.rb +7 -4
- data/lib/elastic/app-search/api/delete_engine.rb +5 -3
- data/lib/elastic/app-search/api/delete_meta_engine_source.rb +7 -4
- data/lib/elastic/app-search/api/delete_synonym_set.rb +6 -5
- data/lib/elastic/app-search/api/documents.rb +7 -4
- data/lib/elastic/app-search/api/engine.rb +5 -3
- data/lib/elastic/app-search/api/index_documents.rb +7 -4
- data/lib/elastic/app-search/api/list_curations.rb +7 -5
- data/lib/elastic/app-search/api/list_documents.rb +7 -5
- data/lib/elastic/app-search/api/list_engines.rb +7 -5
- data/lib/elastic/app-search/api/list_synonym_sets.rb +7 -5
- data/lib/elastic/app-search/api/log_clickthrough.rb +10 -7
- data/lib/elastic/app-search/api/multi_search.rb +8 -7
- data/lib/elastic/app-search/api/put_curation.rb +9 -8
- data/lib/elastic/app-search/api/put_documents.rb +7 -4
- data/lib/elastic/app-search/api/put_schema.rb +7 -4
- data/lib/elastic/app-search/api/put_search_settings.rb +6 -3
- data/lib/elastic/app-search/api/put_synonym_set.rb +7 -7
- data/lib/elastic/app-search/api/query_suggestion.rb +8 -6
- data/lib/elastic/app-search/api/reset_search_settings.rb +5 -3
- data/lib/elastic/app-search/api/schema.rb +6 -4
- data/lib/elastic/app-search/api/search.rb +5 -3
- data/lib/elastic/app-search/api/search_settings.rb +6 -4
- data/lib/elastic/app-search/api/synonym_set.rb +6 -5
- data/lib/elastic/app-search/api/top_clicks_analytics.rb +9 -7
- data/lib/elastic/app-search/api/top_queries_analytics.rb +8 -6
- data/lib/elastic/app-search/app_search.rb +19 -2
- data/lib/elastic/enterprise-search/api/health.rb +6 -1
- data/lib/elastic/enterprise-search/api/put_read_only.rb +5 -1
- data/lib/elastic/enterprise-search/api/read_only.rb +6 -1
- data/lib/elastic/enterprise-search/api/stats.rb +6 -2
- data/lib/elastic/enterprise-search/api/version.rb +6 -1
- data/lib/elastic/enterprise-search/client.rb +15 -2
- data/lib/elastic/enterprise-search/request.rb +25 -13
- data/lib/elastic/enterprise-search/utils.rb +5 -6
- data/lib/elastic/enterprise-search/version.rb +1 -1
- data/lib/elastic/enterprise_search.rb +1 -1
- data/lib/elastic/workplace-search/api/add_user_permissions.rb +10 -9
- data/lib/elastic/workplace-search/api/create_analytics_event.rb +59 -0
- data/lib/elastic/workplace-search/api/create_external_identity.rb +9 -7
- data/lib/elastic/workplace-search/api/delete_documents.rb +9 -7
- data/lib/elastic/workplace-search/api/delete_external_identity.rb +10 -6
- data/lib/elastic/workplace-search/api/external_identity.rb +10 -6
- data/lib/elastic/workplace-search/api/index_documents.rb +11 -8
- data/lib/elastic/workplace-search/api/list_external_identities.rb +11 -7
- data/lib/elastic/workplace-search/api/list_permissions.rb +11 -7
- data/lib/elastic/workplace-search/api/put_external_identity.rb +10 -9
- data/lib/elastic/workplace-search/api/put_user_permissions.rb +10 -9
- data/lib/elastic/workplace-search/api/remove_user_permissions.rb +10 -9
- data/lib/elastic/workplace-search/api/search.rb +19 -1
- data/lib/elastic/workplace-search/api/user_permissions.rb +10 -6
- data/lib/elastic/workplace-search/workplace_search.rb +26 -1
- data/spec/app-search/api_curations_spec.rb +97 -0
- data/spec/app-search/api_documents_spec.rb +20 -6
- data/spec/app-search/api_engines_spec.rb +4 -4
- data/{lib/generator/templates/_license.erb → spec/app-search/api_log_clickthrough_spec.rb} +18 -0
- data/spec/app-search/api_meta_engines_spec.rb +72 -0
- data/spec/app-search/api_query_suggestion_spec.rb +39 -0
- data/spec/app-search/api_schema_spec.rb +17 -3
- data/spec/app-search/api_search_settings_spec.rb +76 -0
- data/spec/app-search/api_synonyms_spec.rb +79 -0
- data/spec/app-search/client_spec.rb +20 -0
- data/spec/enterprise-search/client_spec.rb +11 -0
- data/spec/enterprise-search/request_spec.rb +22 -0
- data/spec/enterprise-search/utils_spec.rb +46 -0
- data/spec/fixtures/vcr/app_search/add_meta_engine_source.yml +109 -0
- data/spec/fixtures/vcr/app_search/api_documents.yml +56 -0
- data/spec/fixtures/vcr/app_search/{index_documents.yml → api_index_documents.yml} +11 -10
- data/spec/fixtures/vcr/app_search/api_log_clickthrough.yml +54 -0
- data/spec/fixtures/vcr/app_search/api_put_schema.yml +109 -0
- data/spec/fixtures/vcr/app_search/api_put_search_settings.yml +56 -0
- data/spec/fixtures/vcr/app_search/api_query_suggestion.yml +59 -0
- data/spec/fixtures/vcr/app_search/api_reset_search_settings.yml +56 -0
- data/spec/fixtures/vcr/app_search/{schema.yml → api_schema.yml} +12 -11
- data/spec/fixtures/vcr/app_search/api_search_settings.yml +56 -0
- data/spec/fixtures/vcr/app_search/create_curation.yml +113 -0
- data/spec/fixtures/vcr/{create_engine.yml → app_search/create_engine.yml} +0 -0
- data/spec/fixtures/vcr/app_search/create_meta_engine.yml +56 -0
- data/spec/fixtures/vcr/app_search/create_synonym_set.yml +56 -0
- data/spec/fixtures/vcr/app_search/delete_curation.yml +56 -0
- data/spec/fixtures/vcr/{delete_engine.yml → app_search/delete_engine.yml} +0 -0
- data/spec/fixtures/vcr/app_search/delete_meta_engine_source.yml +56 -0
- data/spec/fixtures/vcr/app_search/delete_synonym_set.yml +56 -0
- data/spec/fixtures/vcr/app_search/get_curation.yml +56 -0
- data/spec/fixtures/vcr/{get_engine.yml → app_search/get_engine.yml} +0 -0
- data/spec/fixtures/vcr/app_search/list_curations.yml +56 -0
- data/spec/fixtures/vcr/{list_engines.yml → app_search/list_engines.yml} +0 -0
- data/spec/fixtures/vcr/app_search/list_synonym_sets.yml +56 -0
- data/spec/fixtures/vcr/app_search/multi_query_search.yml +2 -2
- data/spec/fixtures/vcr/app_search/put_curation.yml +113 -0
- data/spec/fixtures/vcr/app_search/put_synonym_set.yml +56 -0
- data/spec/fixtures/vcr/app_search/synonym_set.yml +56 -0
- data/spec/fixtures/vcr/{add_user_permissions.yml → workplace_search/add_user_permissions.yml} +11 -9
- data/spec/fixtures/vcr/{clear_user_permissions.yml → workplace_search/clear_user_permissions.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/create_analytics_event.yml +55 -0
- data/spec/fixtures/vcr/workplace_search/create_external_identity.yml +53 -0
- data/spec/fixtures/vcr/{delete_documents.yml → workplace_search/delete_documents.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/delete_external_identity.yml +53 -0
- data/spec/fixtures/vcr/{index_documents.yml → workplace_search/index_documents.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/list_external_identities.yml +53 -0
- data/spec/fixtures/vcr/{list_permissions.yml → workplace_search/list_permissions.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/oauth_request_token.yml +57 -0
- data/spec/fixtures/vcr/workplace_search/put_external_identity.yml +53 -0
- data/spec/fixtures/vcr/{put_user_permissions.yml → workplace_search/put_user_permissions.yml} +22 -18
- data/spec/fixtures/vcr/{remove_user_permissions.yml → workplace_search/remove_user_permissions.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/retrieve_external_identity.yml +53 -0
- data/spec/fixtures/vcr/workplace_search/search_request.yml +60 -0
- data/spec/fixtures/vcr/{user_permissions_empty.yml → workplace_search/user_permissions_empty.yml} +11 -9
- data/spec/integration/enterprise_search_api_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -0
- data/spec/workplace-search/client_spec.rb +10 -2
- data/spec/workplace-search/create_analytics_event_spec.rb +59 -0
- data/spec/workplace-search/documents_spec.rb +80 -0
- data/spec/workplace-search/external_identities_spec.rb +84 -0
- data/spec/workplace-search/{api_spec.rb → permissions_spec.rb} +14 -66
- data/spec/workplace-search/search_spec.rb +53 -0
- metadata +96 -36
- data/lib/generator/documentation_helper.rb +0 -94
- data/lib/generator/endpoint_generator.rb +0 -119
- data/lib/generator/parameters_exceptions.rb +0 -40
- data/lib/generator/parameters_helper.rb +0 -144
- data/lib/generator/templates/endpoint_template.erb +0 -29
- data/lib/generator/templates/spec_template.erb +0 -1
- data/lib/generator/utils.rb +0 -70
- data/spec/fixtures/vcr/create_document.yml +0 -54
@@ -24,16 +24,34 @@ module Elastic
|
|
24
24
|
# Search - search across available sources with various query tuning options
|
25
25
|
# Issue a Search Query
|
26
26
|
#
|
27
|
+
# @param arguments [Hash] endpoint arguments
|
28
|
+
# @option arguments [String] :access_token OAuth Access Token (*Required*)
|
29
|
+
# @option arguments [Object] :body
|
30
|
+
# @option body [String] :query A string or number used to find related documents
|
31
|
+
# @option body [Boolean] :automatic_query_refinement Set to false to not automatically refine the query by keywords
|
32
|
+
# @option body [Object] :page Paging controls for the result set
|
33
|
+
# @option body [Object] :search_fields Restrict the fulltext search to only specific fields
|
34
|
+
# @option body [Object] :result_fields Restrict the result fields for each item to the specified fields
|
35
|
+
# @option body :filters
|
36
|
+
# @option body :sort
|
37
|
+
# @option body [Object] :facets
|
38
|
+
# @option body [Object] :boosts
|
39
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
40
|
+
#
|
27
41
|
# @see https://www.elastic.co/guide/en/workplace-search/current/workplace-search-search-api.html
|
28
42
|
#
|
29
43
|
def search(arguments = {})
|
44
|
+
raise ArgumentError, "Required parameter 'access_token' missing" unless arguments[:access_token]
|
45
|
+
|
30
46
|
body = arguments.delete(:body) || {}
|
47
|
+
headers = arguments.delete(:headers) || {}
|
31
48
|
|
32
49
|
request(
|
33
50
|
:post,
|
34
51
|
'api/ws/v1/search/',
|
35
52
|
arguments,
|
36
|
-
body
|
53
|
+
body,
|
54
|
+
headers
|
37
55
|
)
|
38
56
|
end
|
39
57
|
end
|
@@ -24,23 +24,27 @@ module Elastic
|
|
24
24
|
# Permissions - Lists all permissions for one user
|
25
25
|
# List permissions for a user
|
26
26
|
#
|
27
|
-
# @param
|
27
|
+
# @param content_source_id [String] Unique ID for a Custom API source, provided upon creation of a Custom API Source (*Required*)
|
28
28
|
# @param arguments [Hash] endpoint arguments
|
29
|
-
# @option
|
29
|
+
# @option arguments [String] :user The username in context (*Required*)
|
30
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
30
31
|
#
|
31
32
|
# @see https://www.elastic.co/guide/en/workplace-search/current/workplace-search-document-permissions-api.html#list-one
|
32
33
|
#
|
33
|
-
def user_permissions(
|
34
|
-
raise ArgumentError, "Required parameter '
|
34
|
+
def user_permissions(content_source_id, arguments = {})
|
35
|
+
raise ArgumentError, "Required parameter 'content_source_id' missing" unless content_source_id
|
35
36
|
raise ArgumentError, "Required parameter 'user' missing" unless arguments[:user]
|
36
37
|
|
37
38
|
user = arguments[:user]
|
38
39
|
|
40
|
+
headers = arguments.delete(:headers) || {}
|
41
|
+
|
39
42
|
request(
|
40
43
|
:get,
|
41
|
-
"api/ws/v1/sources/#{
|
44
|
+
"api/ws/v1/sources/#{content_source_id}/permissions/#{user}/",
|
42
45
|
arguments,
|
43
|
-
{}
|
46
|
+
{},
|
47
|
+
headers
|
44
48
|
)
|
45
49
|
end
|
46
50
|
end
|
@@ -37,7 +37,7 @@ module Elastic
|
|
37
37
|
include Elastic::EnterpriseSearch::WorkplaceSearch::Request
|
38
38
|
include Elastic::EnterpriseSearch::Utils
|
39
39
|
|
40
|
-
#
|
40
|
+
# Create a new Elastic::EnterpriseSearch::WorkplaceSearch::Client client
|
41
41
|
#
|
42
42
|
# @param options [Hash] a hash of configuration options
|
43
43
|
# @option options [String] :access_token the access token for workplace search
|
@@ -53,6 +53,31 @@ module Elastic
|
|
53
53
|
def http_auth=(access_token)
|
54
54
|
@options[:http_auth] = access_token
|
55
55
|
end
|
56
|
+
|
57
|
+
def authorization_url(client_id, redirect_uri)
|
58
|
+
[
|
59
|
+
host,
|
60
|
+
'/ws/oauth/authorize?',
|
61
|
+
'response_type=code&',
|
62
|
+
"client_id=#{client_id}&",
|
63
|
+
"redirect_uri=#{CGI.escape(redirect_uri)}"
|
64
|
+
].join
|
65
|
+
end
|
66
|
+
|
67
|
+
def request_access_token(client_id, client_secret, authorization_code, redirect_uri)
|
68
|
+
response = request(
|
69
|
+
:post,
|
70
|
+
'/ws/oauth/token',
|
71
|
+
{
|
72
|
+
grant_type: 'authorization_code',
|
73
|
+
client_id: client_id,
|
74
|
+
client_secret: client_secret,
|
75
|
+
redirect_uri: redirect_uri,
|
76
|
+
code: authorization_code
|
77
|
+
}
|
78
|
+
)
|
79
|
+
response.body['access_token']
|
80
|
+
end
|
56
81
|
end
|
57
82
|
end
|
58
83
|
end
|
@@ -0,0 +1,97 @@
|
|
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 './api_spec_helper'
|
21
|
+
|
22
|
+
describe Elastic::EnterpriseSearch::AppSearch::Client do
|
23
|
+
context 'curations' do
|
24
|
+
let(:engine_name) { 'books' }
|
25
|
+
|
26
|
+
it 'creates a new curation' do
|
27
|
+
VCR.use_cassette('app_search/create_curation') do
|
28
|
+
response = @client.create_curation(
|
29
|
+
engine_name,
|
30
|
+
queries: ['jungle'],
|
31
|
+
promoted: ['doc-600070f60e9e05e6b7037721'],
|
32
|
+
hidden: ['doc-600070f60e9e05e6b7037729']
|
33
|
+
)
|
34
|
+
expect(response.status).to eq 200
|
35
|
+
expect(response.body['id']).to match(/cur-[0-9a-f]+/)
|
36
|
+
|
37
|
+
response = @client.search(engine_name, query: 'jungle')
|
38
|
+
expect(response.status).to eq 200
|
39
|
+
expect(response.body['results'].count).to eq 1
|
40
|
+
expect(response.body['results'].first['title']['raw']).to eq 'Jungle Tales'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'retrieves a curation by id' do
|
45
|
+
VCR.use_cassette('app_search/get_curation') do
|
46
|
+
response = @client.curation(engine_name, curation_id: 'cur-600202fa0e9e05e6b7037753')
|
47
|
+
|
48
|
+
expect(response.status).to eq 200
|
49
|
+
expect(response.body['id']).to match(/cur-[0-9a-f]+/)
|
50
|
+
expect(response.body['queries']).to eq ['jungle']
|
51
|
+
expect(response.body['promoted']).to eq ['doc-600070f60e9e05e6b7037721']
|
52
|
+
expect(response.body['hidden']).to eq ['doc-600070f60e9e05e6b7037729']
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'updates an existing curation' do
|
57
|
+
VCR.use_cassette('app_search/put_curation') do
|
58
|
+
response = @client.put_curation(
|
59
|
+
engine_name,
|
60
|
+
curation_id: 'cur-600202fa0e9e05e6b7037753',
|
61
|
+
queries: ['jungle'],
|
62
|
+
promoted: ['doc-600070f60e9e05e6b7037729'],
|
63
|
+
hidden: ['doc-600070f60e9e05e6b7037721']
|
64
|
+
)
|
65
|
+
|
66
|
+
expect(response.status).to eq 200
|
67
|
+
expect(response.body['id']).to match(/cur-[0-9a-f]+/)
|
68
|
+
|
69
|
+
response = @client.search(engine_name, query: 'jungle')
|
70
|
+
expect(response.status).to eq 200
|
71
|
+
expect(response.body['results'].count).to eq 1
|
72
|
+
expect(response.body['results'].first['title']['raw']).to eq 'The Jungle Book'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'lists curations' do
|
77
|
+
VCR.use_cassette('app_search/list_curations') do
|
78
|
+
response = @client.list_curations(engine_name)
|
79
|
+
|
80
|
+
expect(response.status).to eq 200
|
81
|
+
expect(response.body['results'].count).to eq 1
|
82
|
+
curation = response.body['results'].first
|
83
|
+
expect(curation['id']).to match(/cur-[0-9a-f]+/)
|
84
|
+
expect(curation['queries']).to eq ['jungle']
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'deletes a curation' do
|
89
|
+
VCR.use_cassette('app_search/delete_curation') do
|
90
|
+
response = @client.delete_curation(engine_name, curation_id: 'cur-6002097c0e9e053992037769')
|
91
|
+
|
92
|
+
expect(response.status).to eq 200
|
93
|
+
expect(response.body).to eq({ 'deleted' => true })
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -26,14 +26,14 @@ describe Elastic::EnterpriseSearch::AppSearch::Client do
|
|
26
26
|
|
27
27
|
context 'documents' do
|
28
28
|
it 'indexes and lists documents' do
|
29
|
-
VCR.use_cassette('app_search/
|
29
|
+
VCR.use_cassette('app_search/api_index_documents') do
|
30
30
|
documents = [
|
31
31
|
{ name: 'Super Lorenzo Bros', year: 1985 },
|
32
32
|
{ name: 'Pack-Man', year: 1980 },
|
33
33
|
{ name: 'Galaxxian', year: 1979 },
|
34
34
|
{ name: 'Audiovisual, the hedgehog', year: '1991' }
|
35
35
|
]
|
36
|
-
response = @client.index_documents(engine_name,
|
36
|
+
response = @client.index_documents(engine_name, documents: documents)
|
37
37
|
expect(response.status).to eq 200
|
38
38
|
expect(response.body.count).to eq 4
|
39
39
|
expect(response.body.map(&:keys)).to eq [['id', 'errors'], ['id', 'errors'], ['id', 'errors'], ['id', 'errors']]
|
@@ -47,6 +47,20 @@ describe Elastic::EnterpriseSearch::AppSearch::Client do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
it 'retrieves documents by ID' do
|
51
|
+
VCR.use_cassette('app_search/api_documents') do
|
52
|
+
ids = ['doc-6005c044ad7f0c8b464b8cc4', 'doc-6005c044ad7f0c8b464b8cc3']
|
53
|
+
response = @client.documents(engine_name, document_ids: ids)
|
54
|
+
|
55
|
+
expect(response.status).to eq 200
|
56
|
+
expect(response.body.count).to eq 2
|
57
|
+
expect(response.body).to include(
|
58
|
+
{ 'name' => 'Galaxxian', 'year' => '1979', 'id' => 'doc-6005c044ad7f0c8b464b8cc4' },
|
59
|
+
{ 'name' => 'Pack-Man', 'year' => '1980', 'id' => 'doc-6005c044ad7f0c8b464b8cc3' }
|
60
|
+
)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
50
64
|
it 'searches for a document' do
|
51
65
|
VCR.use_cassette('app_search/search') do
|
52
66
|
response = @client.search(engine_name, body: { query: 'Pack-Man' })
|
@@ -60,12 +74,12 @@ describe Elastic::EnterpriseSearch::AppSearch::Client do
|
|
60
74
|
it 'deletes a document' do
|
61
75
|
VCR.use_cassette('app_search/index_and_delete_document') do
|
62
76
|
document = { name: 'Princess Zelda', year: 1986 }
|
63
|
-
response = @client.index_documents(engine_name,
|
77
|
+
response = @client.index_documents(engine_name, documents: document)
|
64
78
|
expect(response.status).to eq 200
|
65
79
|
|
66
80
|
id = response.body.first['id']
|
67
81
|
|
68
|
-
response = @client.delete_documents(engine_name,
|
82
|
+
response = @client.delete_documents(engine_name, document_ids: [id])
|
69
83
|
expect(response.status).to eq 200
|
70
84
|
expect(response.body.first['deleted'])
|
71
85
|
end
|
@@ -74,12 +88,12 @@ describe Elastic::EnterpriseSearch::AppSearch::Client do
|
|
74
88
|
it 'updates a document' do
|
75
89
|
VCR.use_cassette('app_search/create_and_update_document') do
|
76
90
|
document = { name: '', year: 1986 }
|
77
|
-
response = @client.index_documents(engine_name,
|
91
|
+
response = @client.index_documents(engine_name, documents: document)
|
78
92
|
expect(response.status).to eq 200
|
79
93
|
|
80
94
|
id = response.body.first['id']
|
81
95
|
|
82
|
-
response = @client.put_documents(engine_name,
|
96
|
+
response = @client.put_documents(engine_name, documents: [{ id: id, year: 1987 }])
|
83
97
|
expect(response.status).to eq 200
|
84
98
|
expect(response.body).to eq [{ 'id' => 'doc-5fa2d4e1389ab975965be3e3', 'errors' => [] }]
|
85
99
|
end
|
@@ -26,7 +26,7 @@ describe Elastic::EnterpriseSearch::AppSearch::Client do
|
|
26
26
|
|
27
27
|
context 'engines' do
|
28
28
|
it 'creates an engine' do
|
29
|
-
VCR.use_cassette(
|
29
|
+
VCR.use_cassette('app_search/create_engine') do
|
30
30
|
response = @client.create_engine(name: 'videogames')
|
31
31
|
|
32
32
|
expect(response.status).to eq 200
|
@@ -35,7 +35,7 @@ describe Elastic::EnterpriseSearch::AppSearch::Client do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'lists engines' do
|
38
|
-
VCR.use_cassette(
|
38
|
+
VCR.use_cassette('app_search/list_engines') do
|
39
39
|
response = @client.list_engines
|
40
40
|
|
41
41
|
expect(response.status).to eq 200
|
@@ -47,7 +47,7 @@ describe Elastic::EnterpriseSearch::AppSearch::Client do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'retrieves an engine by name' do
|
50
|
-
VCR.use_cassette(
|
50
|
+
VCR.use_cassette('app_search/get_engine') do
|
51
51
|
response = @client.engine('videogames')
|
52
52
|
|
53
53
|
expect(response.status).to eq 200
|
@@ -56,7 +56,7 @@ describe Elastic::EnterpriseSearch::AppSearch::Client do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'deletes an engine' do
|
59
|
-
VCR.use_cassette(
|
59
|
+
VCR.use_cassette('app_search/delete_engine') do
|
60
60
|
response = @client.delete_engine('videogames')
|
61
61
|
|
62
62
|
expect(response.status).to eq 200
|
@@ -14,3 +14,21 @@
|
|
14
14
|
# KIND, either express or implied. See the License for the
|
15
15
|
# specific language governing permissions and limitations
|
16
16
|
# under the License.
|
17
|
+
|
18
|
+
# frozen_string_literal: true
|
19
|
+
|
20
|
+
require_relative './api_spec_helper'
|
21
|
+
|
22
|
+
describe Elastic::EnterpriseSearch::AppSearch::Client do
|
23
|
+
context 'api_log_clickthrough' do
|
24
|
+
let(:engine_name) { 'films' }
|
25
|
+
|
26
|
+
it 'logs clicked results' do
|
27
|
+
VCR.use_cassette('app_search/api_log_clickthrough') do
|
28
|
+
response = @client.log_clickthrough(engine_name, query_text: 'moon', document_id: 'doc-id')
|
29
|
+
|
30
|
+
expect(response.status).to eq 200
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,72 @@
|
|
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 './api_spec_helper'
|
21
|
+
|
22
|
+
describe Elastic::EnterpriseSearch::AppSearch::Client do
|
23
|
+
let(:engine_name) { 'new-meta-engine' }
|
24
|
+
|
25
|
+
# TODO: Once we stop using VCR, we need to do create / list / destroy engines
|
26
|
+
|
27
|
+
context 'meta engines' do
|
28
|
+
it 'creates a meta engine' do
|
29
|
+
VCR.use_cassette('app_search/create_meta_engine') do
|
30
|
+
body = {
|
31
|
+
name: engine_name,
|
32
|
+
type: 'meta',
|
33
|
+
source_engines: ['books', 'videogames']
|
34
|
+
}
|
35
|
+
response = @client.create_engine(name: engine_name, body: body)
|
36
|
+
|
37
|
+
expect(response.status).to eq 200
|
38
|
+
expect(response.body['name']).to eq('new-meta-engine')
|
39
|
+
expect(response.body['type']).to eq('meta')
|
40
|
+
expect(response.body['source_engines'].sort).to eq(['books', 'videogames'])
|
41
|
+
expect(response.body['document_count']).to be > 1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'adds a new source engine to a meta engine' do
|
46
|
+
VCR.use_cassette('app_search/add_meta_engine_source') do
|
47
|
+
# Create new source engine to add:
|
48
|
+
@client.create_engine(name: 'comicbooks')
|
49
|
+
|
50
|
+
response = @client.add_meta_engine_source(engine_name, source_engines: ['comicbooks'])
|
51
|
+
|
52
|
+
expect(response.status).to eq 200
|
53
|
+
expect(response.body['name']).to eq('new-meta-engine')
|
54
|
+
expect(response.body['type']).to eq('meta')
|
55
|
+
expect(response.body['source_engines'].sort).to eq(['books', 'comicbooks', 'videogames'])
|
56
|
+
expect(response.body['document_count']).to be > 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'removes a source engine from a meta engine' do
|
61
|
+
VCR.use_cassette('app_search/delete_meta_engine_source') do
|
62
|
+
response = @client.delete_meta_engine_source(engine_name, source_engines: ['videogames'])
|
63
|
+
|
64
|
+
expect(response.status).to eq 200
|
65
|
+
expect(response.body['name']).to eq('new-meta-engine')
|
66
|
+
expect(response.body['type']).to eq('meta')
|
67
|
+
expect(response.body['source_engines'].sort).to eq(['books', 'comicbooks'])
|
68
|
+
expect(response.body['document_count']).to be > 1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,39 @@
|
|
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 './api_spec_helper'
|
21
|
+
|
22
|
+
describe Elastic::EnterpriseSearch::AppSearch::Client do
|
23
|
+
context 'api_query_suggestion' do
|
24
|
+
let(:engine_name) { 'films' }
|
25
|
+
|
26
|
+
it 'provides query suggestions' do
|
27
|
+
VCR.use_cassette('app_search/api_query_suggestion') do
|
28
|
+
response = @client.query_suggestion(engine_name, query: 'moo')
|
29
|
+
|
30
|
+
expect(response.status).to eq 200
|
31
|
+
|
32
|
+
expect(response.body['results']['documents']).to include(
|
33
|
+
{ 'suggestion' => 'moon' },
|
34
|
+
{ 'suggestion' => 'moon men' }
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|