elastic-app-search 7.5.0 → 7.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8fe929d232cc83ec09ac232658d933a1f5f9082552c3a9435898df52dcd7035
4
- data.tar.gz: 31d85c082b902fc26d5969c930b936465002b2415edd107f3e74809af87e1adf
3
+ metadata.gz: 26d0afae8c9cdefaf96ebf4ba72cbda4509f87327a68badb058fe90b22a772eb
4
+ data.tar.gz: 3edf7e70985084dc6771e1ec7de4a22848bc118ecf54fef8e8b7454228cebed8
5
5
  SHA512:
6
- metadata.gz: 4e488fdcf558f8002c33957c140633384f0707f12123a25d931649b963f3affb2039e4bc0ebee79d2b12fa42cfd2e0ad38272dd45753b36d6e915494d3d03fe9
7
- data.tar.gz: ab987fa529016c6ceba96bc47edb91128d0d6593d7979888d769f92fc8bda512652661729d019d052b899794db2ffa2ee20b12f7c3251f73828a5d1c77971989
6
+ metadata.gz: dbafac3cc2a8902a958a3a95a693230671c0ac2fcfbf255f296e5010b4f1659285fee4306e10a92d92b2b5f26743714043c52b0232deb519796f947a09a8a36a
7
+ data.tar.gz: 4d6b6a32d0b9b3cdd610898c596a83dc4ea6bcc4679b9424d4d9f1e62a66d13a11c9999ae6b9d7d523e34fc89a00bbc60c065d5dadcfaf2e0211191e373627ba
data/README.md CHANGED
@@ -1,8 +1,18 @@
1
+ > **⚠️ This client is deprecated ⚠️**
2
+ >
3
+ > As of Enterprise Search version 7.10.0, we are directing users to the new [Enterprise Search Ruby Client](https://github.com/elastic/enterprise-search-ruby) and
4
+ > deprecating this client.
5
+ >
6
+ > This client will be compatible with all Enterprise Search 7.x releases, but will not be compatible with 8.x releases. Our development effort on this project will
7
+ > be limited to bug fixes. All future enhancements will be focused on the Enterprise Search Ruby Client.
8
+ >
9
+ > Thank you! - Elastic
10
+
1
11
  <p align="center"><img src="https://github.com/elastic/app-search-ruby/blob/master/logo-app-search.png?raw=true" alt="Elastic App Search Logo"></p>
2
12
 
3
13
  <p align="center"><a href="https://circleci.com/gh/elastic/app-search-ruby"><img src="https://circleci.com/gh/elastic/app-search-ruby.svg?style=svg" alt="CircleCI build"></a></p>
4
14
 
5
- > A first-party Ruby client for building excellent, relevant search experiences with Elastic App Search.
15
+ > A first-party Ruby client for building excellent, relevant search experiences with [Elastic App Search](https://www.elastic.co/products/app-search).
6
16
 
7
17
  ## Contents
8
18
 
@@ -25,7 +35,7 @@ To install the gem, execute:
25
35
  gem install elastic-app-search
26
36
  ```
27
37
 
28
- Or place `gem 'elastic-app-search', '~> 7.5.0'` in your `Gemfile` and run `bundle install`.
38
+ Or place `gem 'elastic-app-search', '~> 7.10.0'` in your `Gemfile` and run `bundle install`.
29
39
 
30
40
  ## Versioning
31
41
 
@@ -35,34 +45,37 @@ To guarantee compatibility, use the most recent version of this library within t
35
45
 
36
46
  For example, for App Search `7.3`, use `7.3` of this library or above, but not `8.0`.
37
47
 
38
- If you are a [SaaS](https://app.swiftype.com/as) user, simply use the most recent version of this library.
48
+ If you are using the [SaaS version available on swiftype.com](https://app.swiftype.com/as) of App Search, you should use the version 7.5.x of the client.
39
49
 
40
50
  ## Usage
41
51
 
42
- ### Setup: Configuring the client and authentication
52
+ #### Setup: Configuring the client and authentication
43
53
 
44
- Create a new instance of the Elastic App Search Client. This requires your `[HOST_IDENTIFIER]`, which
45
- identifies the unique hostname of the App Search API that is associated with your App Search account.
46
- It also requires a valid `[API_KEY]`, which authenticates requests to the API. You can use any key type with the client, however each has a different scope. For more information on keys, check out the [documentation](https://swiftype.com/documentation/app-search/credentials).
54
+ Using this client assumes that you have already an instance of [Elastic App Search](https://www.elastic.co/products/app-search) up and running.
47
55
 
48
- You can find your `[API_KEY]` and your `[HOST_IDENTIFIER]` within the [Credentials](https://app.swiftype.com/as/credentials) menu:
56
+ Once done, a client can be instantiated using the `[API_KEY]` and the `[API_ENDPOINT]` URL of your App Search setup:
49
57
 
50
58
  ```ruby
51
59
  require 'elastic-app-search'
52
60
 
53
- client = Elastic::AppSearch::Client.new(:host_identifier => 'host-c5s2mj', :api_key => 'private-mu75psc5egt9ppzuycnc2mc3')
61
+ client = Elastic::AppSearch::Client.new(:api_key => 'private-xxxxxxxxxxxxxxxxxxx', :api_endpoint => 'http://localhost:3002/api/as/v1/')
54
62
  ```
55
63
 
56
- ### Using with App Search Managed Deploys
64
+ Note:
65
+
66
+ The `[API_KEY]` authenticates requests to the API.
67
+ You can use any key type with the client, however each has a different scope.
68
+ For more information on keys, check out the [documentation](https://swiftype.com/documentation/app-search/api/credentials).
69
+
70
+ ##### Swiftype.com App Search users:
57
71
 
58
- The client can be configured to use a managed deploy by using the
59
- `api_endpoint` parameter. Since managed deploys do not rely on a `[HOST_IDENTIFIER]`
60
- , it can be omitted.
72
+ When using the [SaaS version available on swiftype.com](https://app.swiftype.com/as) of App Search, you can configure the client using your `[HOST_IDENTIFIER]` instead of the `[API_ENDPOINT]`.
73
+ The `[HOST_IDENTIFIER]` can be found within the [Credentials](https://app.swiftype.com/as#/credentials) menu.
61
74
 
62
75
  ```ruby
63
76
  require 'elastic-app-search'
64
77
 
65
- client = Elastic::AppSearch::Client.new(:api_key => 'private-mu75psc5egt9ppzuycnc2mc3', :api_endpoint => 'http://localhost:3002/api/as/v1/')
78
+ client = Elastic::AppSearch::Client.new(:host_identifier => 'host-c5s2mj', :api_key => 'private-xxxxxxxxxxxxxxxxxxx')
66
79
  ```
67
80
 
68
81
  ### API Methods
@@ -176,6 +189,33 @@ engine_name = 'favorite-videos'
176
189
  client.destroy_engine(engine_name)
177
190
  ```
178
191
 
192
+ #### Creating Meta Engines
193
+
194
+ ```ruby
195
+ engine_name = 'videos-engine'
196
+ sources_engines = ['favorite-videos', 'all-videos']
197
+
198
+ client.create_meta_engine(engine_name, source_engines)
199
+ ```
200
+
201
+ #### Adding Meta Engines Source
202
+
203
+ ```ruby
204
+ engine_name = 'videos-engine'
205
+ sources_engines = ['fun-videos', 'cat-videos']
206
+
207
+ client.add_meta_engine_sources(engine_name, source_engines)
208
+ ```
209
+
210
+ #### Adding Meta Engines Source
211
+
212
+ ```ruby
213
+ engine_name = 'videos-engine'
214
+ sources_engines = ['nsfw-videos']
215
+
216
+ client.delete_meta_engine_sources(engine_name, source_engines)
217
+ ```
218
+
179
219
  #### Searching
180
220
 
181
221
  ```ruby
@@ -277,6 +317,7 @@ Creating a search key that will only return the title field.
277
317
 
278
318
  ```ruby
279
319
  public_search_key = 'search-xxxxxxxxxxxxxxxxxxxxxxxx'
320
+ # This name must match the name of the key above from your App Search dashboard
280
321
  public_search_key_name = 'search-key'
281
322
  enforced_options = {
282
323
  result_fields: { title: { raw: {} } },
@@ -285,7 +326,8 @@ enforced_options = {
285
326
 
286
327
  signed_search_key = Elastic::AppSearch::Client.create_signed_search_key(public_search_key, public_search_key_name, enforced_options)
287
328
 
288
- client = Elastic::AppSearch::Client.new(host_identifier: 'host-c5s2mj', api_key: signed_search_key)
329
+ client = Elastic::AppSearch::Client.new(:api_key => signed_search_key, :api_endpoint => 'http://localhost:3002/api/as/v1/')
330
+
289
331
  client.search('national-parks-demo', 'everglade')
290
332
  ```
291
333
 
@@ -13,6 +13,7 @@ module Elastic
13
13
  autoload :Curations, 'elastic/app-search/client/curations'
14
14
  autoload :Documents, 'elastic/app-search/client/documents'
15
15
  autoload :Engines, 'elastic/app-search/client/engines'
16
+ autoload :MetaEngines, 'elastic/app-search/client/meta_engines'
16
17
  autoload :Logs, 'elastic/app-search/client/logs'
17
18
  autoload :Schema, 'elastic/app-search/client/schema'
18
19
  autoload :Search, 'elastic/app-search/client/search'
@@ -69,6 +70,7 @@ module Elastic
69
70
  include Elastic::AppSearch::Client::Curations
70
71
  include Elastic::AppSearch::Client::Documents
71
72
  include Elastic::AppSearch::Client::Engines
73
+ include Elastic::AppSearch::Client::MetaEngines
72
74
  include Elastic::AppSearch::Client::Logs
73
75
  include Elastic::AppSearch::Client::Schema
74
76
  include Elastic::AppSearch::Client::Search
@@ -0,0 +1,23 @@
1
+ module Elastic
2
+ module AppSearch
3
+ class Client
4
+ module MetaEngines
5
+
6
+ ENGINE_TYPE_META = 'meta'.freeze()
7
+
8
+ def create_meta_engine(engine_name, source_engines)
9
+ post('engines', :name => engine_name, :type => ENGINE_TYPE_META, :source_engines => source_engines)
10
+ end
11
+
12
+ def add_meta_engine_sources(engine_name, source_engines)
13
+ post("engines/#{engine_name}/source_engines", source_engines)
14
+ end
15
+
16
+ def delete_meta_engine_sources(engine_name, source_engines)
17
+ delete("engines/#{engine_name}/source_engines", source_engines)
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  module Elastic
2
2
  module AppSearch
3
- VERSION = '7.5.0'
3
+ VERSION = '7.10.0'
4
4
  end
5
5
  end
@@ -27,17 +27,33 @@ describe Elastic::AppSearch::Client do
27
27
 
28
28
  describe 'Requests' do
29
29
  it 'should include client name and version in headers' do
30
- stub_request(:any, "#{client_options[:host_identifier]}.api.swiftype.com/api/as/v1/engines")
31
- client.list_engines
32
- expect(WebMock).to(
33
- have_requested(:get, "https://#{client_options[:host_identifier]}.api.swiftype.com/api/as/v1/engines")
34
- .with(
35
- :headers => {
36
- 'X-Swiftype-Client' => 'elastic-app-search-ruby',
37
- 'X-Swiftype-Client-Version' => Elastic::AppSearch::VERSION
38
- }
30
+ if (client_options[:api_endpoint])
31
+ stub_request(:any, "#{client_options[:api_endpoint]}engines")
32
+ client.list_engines
33
+ expect(WebMock).to(
34
+ have_requested(:get, "#{client_options[:api_endpoint]}engines")
35
+ .with(
36
+ :headers => {
37
+ 'X-Swiftype-Client' => 'elastic-app-search-ruby',
38
+ 'X-Swiftype-Client-Version' => Elastic::AppSearch::VERSION
39
+ }
40
+ )
39
41
  )
40
- )
42
+ else
43
+ # CI runs against saas, so we keep this around for now. CI should be updated
44
+ # to use slef-managed and we should drop support "host_identifier" this.
45
+ stub_request(:any, "#{client_options[:host_identifier]}.api.swiftype.com/api/as/v1/engines")
46
+ client.list_engines
47
+ expect(WebMock).to(
48
+ have_requested(:get, "https://#{client_options[:host_identifier]}.api.swiftype.com/api/as/v1/engines")
49
+ .with(
50
+ :headers => {
51
+ 'X-Swiftype-Client' => 'elastic-app-search-ruby',
52
+ 'X-Swiftype-Client-Version' => Elastic::AppSearch::VERSION
53
+ }
54
+ )
55
+ )
56
+ end
41
57
  end
42
58
  end
43
59
 
@@ -71,7 +71,7 @@ describe Elastic::AppSearch::Client::Documents do
71
71
  it 'should return respective errors in an array of document processing hashes' do
72
72
  expected = [
73
73
  { 'id' => anything, 'errors' => [] },
74
- { 'id' => anything, 'errors' => ['Invalid field type: id must be less than 800 characters'] },
74
+ { 'id' => anything, 'errors' => [anything] },
75
75
  ]
76
76
  expect(subject).to(match(expected))
77
77
  end
@@ -126,34 +126,5 @@ describe Elastic::AppSearch::Client::Documents do
126
126
  expect(response[1]['id']).to(eq(second_document_id))
127
127
  end
128
128
  end
129
-
130
- describe '#list_documents' do
131
- let(:documents) { [first_document, second_document] }
132
- let(:first_document_id) { 'id' }
133
- let(:first_document) { { 'id' => first_document_id, 'url' => 'https://www.youtube.com/watch?v=v1uyQZNg2vE' } }
134
- let(:second_document_id) { 'another_id' }
135
- let(:second_document) { { 'id' => second_document_id, 'url' => 'https://www.youtube.com/watch?v=9T1vfsHYiKY' } }
136
-
137
- before do
138
- client.index_documents(engine_name, documents)
139
- end
140
-
141
- context 'when no options are specified' do
142
- it 'will return all documents' do
143
- response = client.list_documents(engine_name)
144
- expect(response['results'].size).to(eq(2))
145
- expect(response['results'][0]['id']).to(eq(first_document_id))
146
- expect(response['results'][1]['id']).to(eq(second_document_id))
147
- end
148
- end
149
-
150
- context 'when options are specified' do
151
- it 'will return all documents' do
152
- response = client.list_documents(engine_name, :page => { :size => 1, :current => 2 })
153
- expect(response['results'].size).to(eq(1))
154
- expect(response['results'][0]['id']).to(eq(second_document_id))
155
- end
156
- end
157
- end
158
129
  end
159
130
  end
@@ -0,0 +1,25 @@
1
+ describe Elastic::AppSearch::Client::Documents do
2
+ include_context 'App Search Credentials'
3
+ include_context 'Static Test Engine'
4
+
5
+ let(:client) { Elastic::AppSearch::Client.new(client_options) }
6
+
7
+ context 'Documents' do
8
+ describe '#list_documents' do
9
+ context 'when no options are specified' do
10
+ it 'will return all documents' do
11
+ response = client.list_documents(engine_name)
12
+ expect(response['results'].size).to(eq(2))
13
+ expect(response['results'].map { |d| d['id'] }).to(include(document1['id'], document2['id']))
14
+ end
15
+ end
16
+
17
+ context 'when options are specified' do
18
+ it 'will return all documents' do
19
+ response = client.list_documents(engine_name, :page => { :size => 1, :current => 2 })
20
+ expect(response['results'].size).to(eq(1))
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,73 @@
1
+ describe Elastic::AppSearch::Client::MetaEngines do
2
+ include_context 'App Search Credentials'
3
+ include_context 'Engine Name'
4
+ include_context 'Meta Engine Name'
5
+ include_context 'Test Engine'
6
+
7
+ let(:client) { Elastic::AppSearch::Client.new(client_options) }
8
+ let(:source_engines) { [engine_name] }
9
+
10
+ # CI currently runs against SaaS. This feature is a Self-Managed only feature.
11
+ context 'Meta Engines', :skip => "Unable to test Self-Managed features in CI." do
12
+
13
+ after do
14
+ client.destroy_engine(meta_engine_name) rescue Elastic::AppSearch::NonExistentRecord
15
+ end
16
+
17
+ context '#create_meta_engine' do
18
+ it 'should create a meta engine when given a right set of parameters' do
19
+ expect { client.get_engine(meta_engine_name) }.to raise_error(Elastic::AppSearch::NonExistentRecord)
20
+ client.create_meta_engine(meta_engine_name, source_engines)
21
+ expect { client.get_engine(meta_engine_name) }.to_not raise_error
22
+ end
23
+
24
+ it 'should return a meta engine object' do
25
+ engine = client.create_meta_engine(meta_engine_name, source_engines)
26
+ expect(engine).to be_kind_of(Hash)
27
+ expect(engine['name']).to eq(meta_engine_name)
28
+ expect(engine['type']).to eq('meta')
29
+ expect(engine['source_engines']).to eq(source_engines)
30
+ end
31
+
32
+ it 'should return an error when the engine source engine is empty' do
33
+ expect { client.create_meta_engine(engine_name, []) }.to(raise_error) do |e|
34
+ expect(e).to be_a(Elastic::AppSearch::BadRequest)
35
+ expect(e.errors).to eq(['Source engines are required for meta engines'])
36
+ end
37
+ end
38
+ end
39
+
40
+ context '#add_meta_engine_sources' do
41
+ before do
42
+ client.create_meta_engine(meta_engine_name, source_engines)
43
+ client.delete_meta_engine_sources(meta_engine_name, source_engines)
44
+ end
45
+
46
+ it 'should add the source engine' do
47
+ expect { client.add_meta_engine_sources(meta_engine_name, source_engines) }.to_not raise_error do |engine|
48
+ expect(engine).to be_kind_of(Hash)
49
+ expect(engine['name']).to eq(meta_engine_name)
50
+ expect(engine['type']).to eq('meta')
51
+ expect(engine['source_engines']).to be_kind_of(Array)
52
+ expect(engine['source_engines']).to eq(source_engines)
53
+ end
54
+ end
55
+ end
56
+
57
+ context '#delete_meta_engine_sources' do
58
+ before do
59
+ client.create_meta_engine(meta_engine_name, source_engines)
60
+ end
61
+
62
+ it 'should remove the source engine' do
63
+ expect { client.delete_meta_engine_sources(meta_engine_name, source_engines) }.to_not raise_error do |engine|
64
+ expect(engine).to be_kind_of(Hash)
65
+ expect(engine['name']).to eq(meta_engine_name)
66
+ expect(engine['type']).to eq('meta')
67
+ expect(engine['source_engines']).to be_kind_of(Array)
68
+ expect(engine['source_engines']).to be_empty
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -54,6 +54,10 @@ RSpec.shared_context 'Engine Name' do
54
54
  let(:engine_name) { "ruby-client-test-#{SecureRandom.hex}" }
55
55
  end
56
56
 
57
+ RSpec.shared_context 'Meta Engine Name' do
58
+ let(:meta_engine_name) { "ruby-client-test-#{SecureRandom.hex}" }
59
+ end
60
+
57
61
  RSpec.shared_context 'Test Engine' do
58
62
  let(:engine_name) { "ruby-client-test-#{SecureRandom.hex}" }
59
63
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic-app-search
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.5.0
4
+ version: 7.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quin Hoxie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-02 00:00:00.000000000 Z
11
+ date: 2020-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -114,6 +114,7 @@ files:
114
114
  - lib/elastic/app-search/client/documents.rb
115
115
  - lib/elastic/app-search/client/engines.rb
116
116
  - lib/elastic/app-search/client/logs.rb
117
+ - lib/elastic/app-search/client/meta_engines.rb
117
118
  - lib/elastic/app-search/client/query_suggestion.rb
118
119
  - lib/elastic/app-search/client/schema.rb
119
120
  - lib/elastic/app-search/client/search.rb
@@ -134,7 +135,9 @@ files:
134
135
  - spec/documents_spec.rb
135
136
  - spec/engines_spec.rb
136
137
  - spec/exceptions_spec.rb
138
+ - spec/list_documents_spec.rb
137
139
  - spec/logs_spec.rb
140
+ - spec/meta_engines_spec.rb
138
141
  - spec/query_suggestion_spec.rb
139
142
  - spec/schema_spec.rb
140
143
  - spec/search_settings_spec.rb
@@ -160,8 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
163
  - !ruby/object:Gem::Version
161
164
  version: '0'
162
165
  requirements: []
163
- rubyforge_project:
164
- rubygems_version: 2.7.6
166
+ rubygems_version: 3.0.3
165
167
  signing_key:
166
168
  specification_version: 4
167
169
  summary: Official gem for accessing the Elastic App Search API
@@ -175,7 +177,9 @@ test_files:
175
177
  - spec/documents_spec.rb
176
178
  - spec/engines_spec.rb
177
179
  - spec/exceptions_spec.rb
180
+ - spec/list_documents_spec.rb
178
181
  - spec/logs_spec.rb
182
+ - spec/meta_engines_spec.rb
179
183
  - spec/query_suggestion_spec.rb
180
184
  - spec/schema_spec.rb
181
185
  - spec/search_settings_spec.rb