swiftype-app-search 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 236cc084c39977f3fff52da0695f9d90e66c3209a7596d9ca6805239828be122
4
- data.tar.gz: dabefe87c883d2aad2a6991140e03b4dbfc1c6e8a78c0903e9a90dbe25065f72
3
+ metadata.gz: 8409dce98dbe9ef896e5cc4533cb6b2e6f320fc00b2e1d6d7091c9c1976f3d15
4
+ data.tar.gz: f3fcbee95672e8a930c7b1f1d182b49b5391e9d843fcdf9875b4b3e26d8b2c0e
5
5
  SHA512:
6
- metadata.gz: 86c5e5978343a171276ef98d8b84fb6e780a32781d27486d7b172b0d0d64a1864441a0d0cb1ff8322851483e6163bc269df79a6bfda0aa094e3f2ebc75c41935
7
- data.tar.gz: 12650e7cd5ff571ebe6243824bb4caa07205a8e8889c45fb07b5ac6e1d32bb75f89b48c4f08923335910c2be598697bf1cb90417f7d5fb1d948688725181ac8c
6
+ metadata.gz: 1f94fc9f964ebbba4e37401cd455a551116f9041b5aeba8b6caa56c3fb0bf0ba324f2dca3e434cff3717e9d444b3fa934e21d7a6cbb3401ee7e3f9527f8606a3
7
+ data.tar.gz: 57d7533faa0660c2b542e1438f514e1aa22978bcd6de13af6d320d4d26f6c675b3cde2d5f3585cf4f7fa2595aeba2c75fe20da05fb1f3655af149110a6d96395
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Elastic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,8 +1,23 @@
1
- # Ruby client for the Swiftype App Search API
1
+ <p align="center"><img src="https://github.com/swiftype/swiftype-app-search-ruby/blob/master/logo-app-search.png?raw=true" alt="Elastic App Search Logo"></p>
2
2
 
3
- [![CircleCI](https://circleci.com/gh/swiftype/swiftype-app-search-ruby.svg?style=svg)](https://circleci.com/gh/swiftype/swiftype-app-search-ruby)
3
+ <p align="center"><a href="https://circleci.com/gh/swiftype/swiftype-app-search-ruby"><img src="https://circleci.com/gh/swiftype/swiftype-app-search-ruby.svg?style=svg" alt="CircleCI buidl"></a>
4
+ <a href="https://github.com/swiftype/swiftype-app-search-ruby/releases"><img src="https://img.shields.io/github/release/swiftype/swiftype-app-search-ruby/all.svg?style=flat-square" alt="GitHub release" /></a></p>
4
5
 
5
- ## Installation
6
+ > A first-party Ruby client for building excellent, relevant search experiences with Elastic App Search.
7
+
8
+ ## Contents
9
+
10
+ + [Getting started](#getting-started-)
11
+ + [Usage](#usage)
12
+ + [Running Tests](#running-tests)
13
+ + [Debugging API Calls](#debugging-api-calls)
14
+ + [FAQ](#faq-)
15
+ + [Contribute](#contribute-)
16
+ + [License](#license-)
17
+
18
+ ***
19
+
20
+ ## Getting started 🐣
6
21
 
7
22
  To install the gem, execute:
8
23
 
@@ -10,7 +25,7 @@ To install the gem, execute:
10
25
  gem install swiftype-app-search
11
26
  ```
12
27
 
13
- Or place `gem 'swiftype-app-search', '~> 0.4.4` in your `Gemfile` and run `bundle install`.
28
+ Or place `gem 'swiftype-app-search', '~> 0.5.0'` in your `Gemfile` and run `bundle install`.
14
29
 
15
30
  ## Usage
16
31
 
@@ -23,7 +38,17 @@ It also requires a valid `[API_KEY]`, which authenticates requests to the API. Y
23
38
  You can find your `[API_KEY]` and your `[HOST_IDENTIFIER]` within the [Credentials](https://app.swiftype.com/as/credentials) menu:
24
39
 
25
40
  ```ruby
26
- client = SwiftypeAppSearch::Client.new(:host_identifier => 'host-c5s2mj', :api_key => 'api-mu75psc5egt9ppzuycnc2mc3')
41
+ client = SwiftypeAppSearch::Client.new(:host_identifier => 'host-c5s2mj', :api_key => 'private-mu75psc5egt9ppzuycnc2mc3')
42
+ ```
43
+
44
+ ### Using with App Search Managed Deploys
45
+
46
+ The client can be configured to use a managed deploy by using the
47
+ `api_endpoint` parameter. Since managed deploys do not rely on a `[HOST_IDENTIFIER]`
48
+ , it can be omitted.
49
+
50
+ ```ruby
51
+ client = SwiftypeAppSearch::Client.new(:api_key => 'private-mu75psc5egt9ppzuycnc2mc3', :api_endpoint => 'http://localhost:3002/api/as/v1/')
27
52
  ```
28
53
 
29
54
  ### API Methods
@@ -164,6 +189,23 @@ queries = [{
164
189
  client.multi_search(engine_name, queries)
165
190
  ```
166
191
 
192
+ #### Query Suggestion
193
+
194
+ ```ruby
195
+ engine_name = 'favorite-videos'
196
+
197
+ options = {
198
+ :size => 3,
199
+ :types => {
200
+ :documents => {
201
+ :fields => ['title']
202
+ }
203
+ }
204
+ }
205
+
206
+ client.query_suggestion(engine_name, 'cat', options)
207
+ ```
208
+
167
209
  ## Running Tests
168
210
 
169
211
  ```bash
@@ -193,6 +235,29 @@ If you need to debug an API call made by the client, there are a few things you
193
235
  to Swiftype Customer Support to help us quickly find your API request and help you troubleshoot
194
236
  your issues.
195
237
 
196
- ## Contributions
238
+ ## FAQ 🔮
239
+
240
+ ### Where do I report issues with the client?
241
+
242
+ If something is not working as expected, please open an [issue](https://github.com/swiftype/swiftype-app-search-ruby/issues/new).
243
+
244
+ ### Where can I learn more about App Search?
245
+
246
+ Your best bet is to read the [documentation](https://swiftype.com/documentation/app-search).
247
+
248
+ ### Where else can I go to get help?
249
+
250
+ You can checkout the [Elastic App Search community discuss forums](https://discuss.elastic.co/c/app-search).
251
+
252
+ ## Contribute 🚀
253
+
254
+ We welcome contributors to the project. Before you begin, a couple notes...
255
+
256
+ + Before opening a pull request, please create an issue to [discuss the scope of your proposal](https://github.com/swiftype/swiftype-app-search-ruby/issues).
257
+ + Please write simple code and concise documentation, when appropriate.
258
+
259
+ ## License 📗
260
+
261
+ [MIT](https://github.com/swiftype/swiftype-app-search-ruby/blob/master/LICENSE.txt) © [Elastic](https://github.com/elastic)
197
262
 
198
- To contribute code, please fork the repository and submit a pull request.
263
+ Thank you to all the [contributors](https://github.com/swiftype/swiftype-app-search-ruby/graphs/contributors)!
@@ -9,6 +9,7 @@ module SwiftypeAppSearch
9
9
  autoload :Documents, 'swiftype-app-search/client/documents'
10
10
  autoload :Engines, 'swiftype-app-search/client/engines'
11
11
  autoload :Search, 'swiftype-app-search/client/search'
12
+ autoload :QuerySuggestion, 'swiftype-app-search/client/query_suggestion'
12
13
 
13
14
  DEFAULT_TIMEOUT = 15
14
15
 
@@ -57,5 +58,6 @@ module SwiftypeAppSearch
57
58
  include SwiftypeAppSearch::Client::Engines
58
59
  include SwiftypeAppSearch::Client::Search
59
60
  include SwiftypeAppSearch::Client::SignedSearchOptions
61
+ include SwiftypeAppSearch::Client::QuerySuggestion
60
62
  end
61
63
  end
@@ -0,0 +1,17 @@
1
+ module SwiftypeAppSearch
2
+ class Client
3
+ module QuerySuggestion
4
+ # Request Query Suggestions
5
+ #
6
+ # @param [String] engine_name the unique Engine name
7
+ # @param [String] query the search query to suggest for
8
+ # @options options see the {App Search API}[https://swiftype.com/documentation/app-search/] for supported search options.
9
+ #
10
+ # @return [Hash] search results
11
+ def query_suggestion(engine_name, query, options = {})
12
+ params = Utils.symbolize_keys(options).merge(:query => query)
13
+ request(:post, "engines/#{engine_name}/query_suggestion", params)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module SwiftypeAppSearch
2
- VERSION = '0.4.4'
2
+ VERSION = '0.5.0'
3
3
  end
Binary file
data/spec/client_spec.rb CHANGED
@@ -324,6 +324,35 @@ describe SwiftypeAppSearch::Client do
324
324
  end
325
325
  end
326
326
 
327
+ context 'QuerySuggest' do
328
+ describe '#query_suggestion' do
329
+ let(:query) { 'cat' }
330
+ let(:options) { { :size => 3, :types => { :documents => { :fields => ['title'] } } } }
331
+
332
+ context 'when options are provided' do
333
+ subject { @static_client.query_suggestion(@static_engine_name, query, options) }
334
+
335
+ it 'should request query suggestions' do
336
+ expect(subject).to match(
337
+ 'meta' => anything,
338
+ 'results' => anything
339
+ )
340
+ end
341
+ end
342
+
343
+ context 'when options are omitted' do
344
+ subject { @static_client.query_suggestion(@static_engine_name, query) }
345
+
346
+ it 'should request query suggestions' do
347
+ expect(subject).to match(
348
+ 'meta' => anything,
349
+ 'results' => anything
350
+ )
351
+ end
352
+ end
353
+ end
354
+ end
355
+
327
356
  context 'Engines' do
328
357
  after do
329
358
  client.destroy_engine(engine_name) rescue SwiftypeAppSearch::NonExistentRecord
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swiftype-app-search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.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: 2018-10-23 00:00:00.000000000 Z
11
+ date: 2019-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -99,7 +99,7 @@ files:
99
99
  - ".rubocop.yml"
100
100
  - ".travis.yml"
101
101
  - Gemfile
102
- - LICENSE.txt
102
+ - LICENSE
103
103
  - README.md
104
104
  - Rakefile
105
105
  - lib/data/ca-bundle.crt
@@ -107,11 +107,13 @@ files:
107
107
  - lib/swiftype-app-search/client.rb
108
108
  - lib/swiftype-app-search/client/documents.rb
109
109
  - lib/swiftype-app-search/client/engines.rb
110
+ - lib/swiftype-app-search/client/query_suggestion.rb
110
111
  - lib/swiftype-app-search/client/search.rb
111
112
  - lib/swiftype-app-search/exceptions.rb
112
113
  - lib/swiftype-app-search/request.rb
113
114
  - lib/swiftype-app-search/utils.rb
114
115
  - lib/swiftype-app-search/version.rb
116
+ - logo-app-search.png
115
117
  - script/console
116
118
  - spec/client_spec.rb
117
119
  - spec/config_helper.rb
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- Copyright 2017 Swiftype, Inc.
2
- http://swiftype.com/
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining
5
- a copy of this software and associated documentation files (the
6
- "Software"), to deal in the Software without restriction, including
7
- without limitation the rights to use, copy, modify, merge, publish,
8
- distribute, sublicense, and/or sell copies of the Software, and to
9
- permit persons to whom the Software is furnished to do so, subject to
10
- the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.