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.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/jobs/elastic+enterprise-search-ruby+7.10.0.beta.1.yml +12 -0
  3. data/.ci/test-matrix.yml +2 -1
  4. data/.github/workflows/testing.yml +1 -1
  5. data/.gitignore +1 -0
  6. data/CONTRIBUTING.md +43 -0
  7. data/Gemfile +1 -0
  8. data/README.md +7 -225
  9. data/Rakefile +1 -24
  10. data/docs/guide/app-search-api.asciidoc +172 -0
  11. data/docs/guide/connecting.asciidoc +125 -0
  12. data/docs/guide/development.asciidoc +42 -0
  13. data/docs/guide/enterprise-search-api.asciidoc +46 -0
  14. data/docs/guide/index.asciidoc +17 -0
  15. data/docs/guide/installation.asciidoc +18 -0
  16. data/docs/guide/overview.asciidoc +59 -0
  17. data/docs/guide/workplace-search-api.asciidoc +121 -0
  18. data/elastic-enterprise-search.gemspec +5 -4
  19. data/lib/elastic/app-search/api/add_meta_engine_source.rb +7 -4
  20. data/lib/elastic/app-search/api/api_logs.rb +15 -16
  21. data/lib/elastic/app-search/api/count_analytics.rb +7 -5
  22. data/lib/elastic/app-search/api/create_curation.rb +8 -6
  23. data/lib/elastic/app-search/api/create_engine.rb +9 -7
  24. data/lib/elastic/app-search/api/create_synonym_set.rb +6 -5
  25. data/lib/elastic/app-search/api/curation.rb +6 -5
  26. data/lib/elastic/app-search/api/delete_curation.rb +6 -5
  27. data/lib/elastic/app-search/api/delete_documents.rb +7 -4
  28. data/lib/elastic/app-search/api/delete_engine.rb +5 -3
  29. data/lib/elastic/app-search/api/delete_meta_engine_source.rb +7 -4
  30. data/lib/elastic/app-search/api/delete_synonym_set.rb +6 -5
  31. data/lib/elastic/app-search/api/documents.rb +7 -4
  32. data/lib/elastic/app-search/api/engine.rb +5 -3
  33. data/lib/elastic/app-search/api/index_documents.rb +7 -4
  34. data/lib/elastic/app-search/api/list_curations.rb +7 -5
  35. data/lib/elastic/app-search/api/list_documents.rb +7 -5
  36. data/lib/elastic/app-search/api/list_engines.rb +7 -5
  37. data/lib/elastic/app-search/api/list_synonym_sets.rb +7 -5
  38. data/lib/elastic/app-search/api/log_clickthrough.rb +10 -7
  39. data/lib/elastic/app-search/api/multi_search.rb +8 -7
  40. data/lib/elastic/app-search/api/put_curation.rb +9 -8
  41. data/lib/elastic/app-search/api/put_documents.rb +7 -4
  42. data/lib/elastic/app-search/api/put_schema.rb +7 -4
  43. data/lib/elastic/app-search/api/put_search_settings.rb +6 -3
  44. data/lib/elastic/app-search/api/put_synonym_set.rb +7 -7
  45. data/lib/elastic/app-search/api/query_suggestion.rb +8 -6
  46. data/lib/elastic/app-search/api/reset_search_settings.rb +5 -3
  47. data/lib/elastic/app-search/api/schema.rb +6 -4
  48. data/lib/elastic/app-search/api/search.rb +5 -3
  49. data/lib/elastic/app-search/api/search_settings.rb +6 -4
  50. data/lib/elastic/app-search/api/synonym_set.rb +6 -5
  51. data/lib/elastic/app-search/api/top_clicks_analytics.rb +9 -7
  52. data/lib/elastic/app-search/api/top_queries_analytics.rb +8 -6
  53. data/lib/elastic/app-search/app_search.rb +19 -2
  54. data/lib/elastic/enterprise-search/api/health.rb +6 -1
  55. data/lib/elastic/enterprise-search/api/put_read_only.rb +5 -1
  56. data/lib/elastic/enterprise-search/api/read_only.rb +6 -1
  57. data/lib/elastic/enterprise-search/api/stats.rb +6 -2
  58. data/lib/elastic/enterprise-search/api/version.rb +6 -1
  59. data/lib/elastic/enterprise-search/client.rb +15 -2
  60. data/lib/elastic/enterprise-search/request.rb +25 -13
  61. data/lib/elastic/enterprise-search/utils.rb +5 -6
  62. data/lib/elastic/enterprise-search/version.rb +1 -1
  63. data/lib/elastic/enterprise_search.rb +1 -1
  64. data/lib/elastic/workplace-search/api/add_user_permissions.rb +10 -9
  65. data/lib/elastic/workplace-search/api/create_analytics_event.rb +59 -0
  66. data/lib/elastic/workplace-search/api/create_external_identity.rb +9 -7
  67. data/lib/elastic/workplace-search/api/delete_documents.rb +9 -7
  68. data/lib/elastic/workplace-search/api/delete_external_identity.rb +10 -6
  69. data/lib/elastic/workplace-search/api/external_identity.rb +10 -6
  70. data/lib/elastic/workplace-search/api/index_documents.rb +11 -8
  71. data/lib/elastic/workplace-search/api/list_external_identities.rb +11 -7
  72. data/lib/elastic/workplace-search/api/list_permissions.rb +11 -7
  73. data/lib/elastic/workplace-search/api/put_external_identity.rb +10 -9
  74. data/lib/elastic/workplace-search/api/put_user_permissions.rb +10 -9
  75. data/lib/elastic/workplace-search/api/remove_user_permissions.rb +10 -9
  76. data/lib/elastic/workplace-search/api/search.rb +19 -1
  77. data/lib/elastic/workplace-search/api/user_permissions.rb +10 -6
  78. data/lib/elastic/workplace-search/workplace_search.rb +26 -1
  79. data/spec/app-search/api_curations_spec.rb +97 -0
  80. data/spec/app-search/api_documents_spec.rb +20 -6
  81. data/spec/app-search/api_engines_spec.rb +4 -4
  82. data/{lib/generator/templates/_license.erb → spec/app-search/api_log_clickthrough_spec.rb} +18 -0
  83. data/spec/app-search/api_meta_engines_spec.rb +72 -0
  84. data/spec/app-search/api_query_suggestion_spec.rb +39 -0
  85. data/spec/app-search/api_schema_spec.rb +17 -3
  86. data/spec/app-search/api_search_settings_spec.rb +76 -0
  87. data/spec/app-search/api_synonyms_spec.rb +79 -0
  88. data/spec/app-search/client_spec.rb +20 -0
  89. data/spec/enterprise-search/client_spec.rb +11 -0
  90. data/spec/enterprise-search/request_spec.rb +22 -0
  91. data/spec/enterprise-search/utils_spec.rb +46 -0
  92. data/spec/fixtures/vcr/app_search/add_meta_engine_source.yml +109 -0
  93. data/spec/fixtures/vcr/app_search/api_documents.yml +56 -0
  94. data/spec/fixtures/vcr/app_search/{index_documents.yml → api_index_documents.yml} +11 -10
  95. data/spec/fixtures/vcr/app_search/api_log_clickthrough.yml +54 -0
  96. data/spec/fixtures/vcr/app_search/api_put_schema.yml +109 -0
  97. data/spec/fixtures/vcr/app_search/api_put_search_settings.yml +56 -0
  98. data/spec/fixtures/vcr/app_search/api_query_suggestion.yml +59 -0
  99. data/spec/fixtures/vcr/app_search/api_reset_search_settings.yml +56 -0
  100. data/spec/fixtures/vcr/app_search/{schema.yml → api_schema.yml} +12 -11
  101. data/spec/fixtures/vcr/app_search/api_search_settings.yml +56 -0
  102. data/spec/fixtures/vcr/app_search/create_curation.yml +113 -0
  103. data/spec/fixtures/vcr/{create_engine.yml → app_search/create_engine.yml} +0 -0
  104. data/spec/fixtures/vcr/app_search/create_meta_engine.yml +56 -0
  105. data/spec/fixtures/vcr/app_search/create_synonym_set.yml +56 -0
  106. data/spec/fixtures/vcr/app_search/delete_curation.yml +56 -0
  107. data/spec/fixtures/vcr/{delete_engine.yml → app_search/delete_engine.yml} +0 -0
  108. data/spec/fixtures/vcr/app_search/delete_meta_engine_source.yml +56 -0
  109. data/spec/fixtures/vcr/app_search/delete_synonym_set.yml +56 -0
  110. data/spec/fixtures/vcr/app_search/get_curation.yml +56 -0
  111. data/spec/fixtures/vcr/{get_engine.yml → app_search/get_engine.yml} +0 -0
  112. data/spec/fixtures/vcr/app_search/list_curations.yml +56 -0
  113. data/spec/fixtures/vcr/{list_engines.yml → app_search/list_engines.yml} +0 -0
  114. data/spec/fixtures/vcr/app_search/list_synonym_sets.yml +56 -0
  115. data/spec/fixtures/vcr/app_search/multi_query_search.yml +2 -2
  116. data/spec/fixtures/vcr/app_search/put_curation.yml +113 -0
  117. data/spec/fixtures/vcr/app_search/put_synonym_set.yml +56 -0
  118. data/spec/fixtures/vcr/app_search/synonym_set.yml +56 -0
  119. data/spec/fixtures/vcr/{add_user_permissions.yml → workplace_search/add_user_permissions.yml} +11 -9
  120. data/spec/fixtures/vcr/{clear_user_permissions.yml → workplace_search/clear_user_permissions.yml} +11 -9
  121. data/spec/fixtures/vcr/workplace_search/create_analytics_event.yml +55 -0
  122. data/spec/fixtures/vcr/workplace_search/create_external_identity.yml +53 -0
  123. data/spec/fixtures/vcr/{delete_documents.yml → workplace_search/delete_documents.yml} +11 -9
  124. data/spec/fixtures/vcr/workplace_search/delete_external_identity.yml +53 -0
  125. data/spec/fixtures/vcr/{index_documents.yml → workplace_search/index_documents.yml} +11 -9
  126. data/spec/fixtures/vcr/workplace_search/list_external_identities.yml +53 -0
  127. data/spec/fixtures/vcr/{list_permissions.yml → workplace_search/list_permissions.yml} +11 -9
  128. data/spec/fixtures/vcr/workplace_search/oauth_request_token.yml +57 -0
  129. data/spec/fixtures/vcr/workplace_search/put_external_identity.yml +53 -0
  130. data/spec/fixtures/vcr/{put_user_permissions.yml → workplace_search/put_user_permissions.yml} +22 -18
  131. data/spec/fixtures/vcr/{remove_user_permissions.yml → workplace_search/remove_user_permissions.yml} +11 -9
  132. data/spec/fixtures/vcr/workplace_search/retrieve_external_identity.yml +53 -0
  133. data/spec/fixtures/vcr/workplace_search/search_request.yml +60 -0
  134. data/spec/fixtures/vcr/{user_permissions_empty.yml → workplace_search/user_permissions_empty.yml} +11 -9
  135. data/spec/integration/enterprise_search_api_spec.rb +2 -2
  136. data/spec/spec_helper.rb +2 -0
  137. data/spec/workplace-search/client_spec.rb +10 -2
  138. data/spec/workplace-search/create_analytics_event_spec.rb +59 -0
  139. data/spec/workplace-search/documents_spec.rb +80 -0
  140. data/spec/workplace-search/external_identities_spec.rb +84 -0
  141. data/spec/workplace-search/{api_spec.rb → permissions_spec.rb} +14 -66
  142. data/spec/workplace-search/search_spec.rb +53 -0
  143. metadata +96 -36
  144. data/lib/generator/documentation_helper.rb +0 -94
  145. data/lib/generator/endpoint_generator.rb +0 -119
  146. data/lib/generator/parameters_exceptions.rb +0 -40
  147. data/lib/generator/parameters_helper.rb +0 -144
  148. data/lib/generator/templates/endpoint_template.erb +0 -29
  149. data/lib/generator/templates/spec_template.erb +0 -1
  150. data/lib/generator/utils.rb +0 -70
  151. 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 content_source_key [String] Unique key for a Custom API source, provided upon creation of a Custom API Source (*Required*)
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 user [String] The username in context (*Required*)
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(content_source_key, arguments = {})
34
- raise ArgumentError, "Required parameter 'content_source_key' missing" unless content_source_key
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/#{content_source_key}/permissions/#{user}/",
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
- # Crete a new Elastic::EnterpriseSearch::WorkplaceSearch::Client client
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/index_documents') do
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, body: documents)
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, body: document)
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, body: [id])
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, body: document)
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, body: [{ id: id, year: 1987 }])
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(:create_engine) do
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(:list_engines) do
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(:get_engine) do
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(:delete_engine) do
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