swiftype 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +5 -0
- data/README.md +2 -2
- data/lib/swiftype/client.rb +4 -0
- data/lib/swiftype/version.rb +1 -1
- data/spec/client_spec.rb +19 -0
- data/spec/fixtures/vcr/bulk_create_or_update_documents_verbose_failure.yml +47 -0
- data/spec/fixtures/vcr/bulk_create_or_update_documents_verbose_success.yml +51 -0
- metadata +21 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ec1df142277966dde94c63225c977056242a5d70
|
4
|
+
data.tar.gz: e4decec856f184b9c8d1ad9a5774bde8e90cdb04
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46250d369963f704a41c0911d228835e89696ffabdf3d0c60c4e81de1cb90e314202d844d58882f199aef34bd42cfed52cef1b4a904958891bbc0fec9bed2188
|
7
|
+
data.tar.gz: d36c10b224eed2d6281ab2073bc6c849d98659952015d7da9c18cb0952dd937f74f26a8e00c06b305a25c3c87c75d869279fd6f630adad9b1a237b6c3172e5a3
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -24,7 +24,7 @@ To install the gem, execute:
|
|
24
24
|
|
25
25
|
gem install swiftype
|
26
26
|
|
27
|
-
Or place `gem 'swiftype', '~> 1.0.
|
27
|
+
Or place `gem 'swiftype', '~> 1.0.1` in your `Gemfile` and run `bundle install`.
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
@@ -287,7 +287,7 @@ You can also specifiy a date range for queries without results:
|
|
287
287
|
|
288
288
|
## Migrating from previous versions
|
289
289
|
|
290
|
-
swiftype-rb 1.0
|
290
|
+
swiftype-rb 1.0 has been rewritten to be simpler and easier to use. However, it is not compatable with the previous version, 0.0.5.
|
291
291
|
|
292
292
|
To upgrade from the old version of swiftype-rb:
|
293
293
|
|
data/lib/swiftype/client.rb
CHANGED
@@ -301,6 +301,10 @@ module Swiftype
|
|
301
301
|
post("engines/#{engine_id}/document_types/#{document_type_id}/documents/bulk_create_or_update.json", :documents => documents)
|
302
302
|
end
|
303
303
|
|
304
|
+
def create_or_update_documents_verbose(engine_id, document_type_id, documents=[])
|
305
|
+
post("engines/#{engine_id}/document_types/#{document_type_id}/documents/bulk_create_or_update_verbose.json", :documents => documents)
|
306
|
+
end
|
307
|
+
|
304
308
|
def update_document(engine_id, document_type_id, document_id, fields)
|
305
309
|
put("engines/#{engine_id}/document_types/#{document_type_id}/documents/#{document_id}/update_fields.json", { :fields => fields })
|
306
310
|
end
|
data/lib/swiftype/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -286,6 +286,25 @@ describe Swiftype::Client do
|
|
286
286
|
end
|
287
287
|
end
|
288
288
|
|
289
|
+
context '#bulk_create_or_update_documents_verbose' do
|
290
|
+
it 'returns true for all documents successfully created or updated' do
|
291
|
+
VCR.use_cassette(:bulk_create_or_update_documents_verbose_success) do
|
292
|
+
response = client.create_or_update_documents_verbose(engine_slug, document_type_slug, documents)
|
293
|
+
response.should == [true, true]
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
it 'returns a descriptive error message if a document cannot be created or updated due to an error' do
|
298
|
+
documents = [{:external_id => 'failed_doc', :fields => [{:type => :string, :name => :title}]}] # missing value
|
299
|
+
|
300
|
+
VCR.use_cassette(:bulk_create_or_update_documents_verbose_failure) do
|
301
|
+
response = client.create_or_update_documents_verbose(engine_slug, document_type_slug, documents)
|
302
|
+
response.size.should == 1
|
303
|
+
response.first.should match /^Invalid field definition/
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
289
308
|
context '#update_document' do
|
290
309
|
it 'updates a document given its id and fields to update' do
|
291
310
|
fields = {:title => 'awesome new title', :channel_id => 'UC5VA5j05FjETg-iLekcyiBw'}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://hello:@localhost:3000/api/v1/engines/swiftype-api-example/document_types/videos/documents/bulk_create_or_update_verbose.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: "{\"documents\":[{\"external_id\":\"failed_doc\",\"fields\":[{\"type\":\"string\",\"name\":\"title\"}]}]}"
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Swiftype-Ruby/1.0.1
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=utf-8
|
25
|
+
X-Ua-Compatible:
|
26
|
+
- IE=Edge
|
27
|
+
Etag:
|
28
|
+
- "\"45d92cba10f804a2e430c32f79c06377\""
|
29
|
+
Cache-Control:
|
30
|
+
- max-age=0, private, must-revalidate
|
31
|
+
Set-Cookie:
|
32
|
+
- _st_main_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJTI3ODQwNDI1NzU3ZWE0YjkyZDU1NzI5ZjZiMjg0NDM2BjsAVEkiGXdhcmRlbi51c2VyLnJvbGUua2V5BjsAVFsISSIJUm9sZQY7AEZbBlU6Gk1vcGVkOjpCU09OOjpPYmplY3RJZCIRUscPIjrnQFhtAAADMA%3D%3D--67548ff009df98e934a16364aa58b29632bc2cd6;
|
33
|
+
path=/; HttpOnly
|
34
|
+
X-Request-Id:
|
35
|
+
- 525743b187eb7b876042ebc3778d6b84
|
36
|
+
X-Runtime:
|
37
|
+
- '0.156692'
|
38
|
+
Connection:
|
39
|
+
- close
|
40
|
+
Server:
|
41
|
+
- thin 1.5.0 codename Knife
|
42
|
+
body:
|
43
|
+
encoding: UTF-8
|
44
|
+
string: "[\"Invalid field definition: Field definition requires a 'value' attribute\"]"
|
45
|
+
http_version:
|
46
|
+
recorded_at: Thu, 16 Jan 2014 23:13:08 GMT
|
47
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,51 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://hello:@localhost:3000/api/v1/engines/swiftype-api-example/document_types/videos/documents/bulk_create_or_update_verbose.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: "{\"documents\":[{\"external_id\":\"INscMGmhmX4\",\"fields\":[{\"name\":\"url\",\"value\":\"http://www.youtube.com/watch?v=v1uyQZNg2vE\",\"type\":\"enum\"},{\"name\":\"thumbnail_url\",\"value\":\"https://i.ytimg.com/vi/INscMGmhmX4/mqdefault.jpg\",\"type\":\"enum\"},{\"name\":\"channel_id\",\"value\":\"UCTzVrd9ExsI3Zgnlh3_btLg\",\"type\":\"enum\"},{\"name\":\"title\",\"value\":\"The
|
9
|
+
Original Grumpy Cat\",\"type\":\"string\"},{\"name\":\"category_name\",\"value\":\"Pets
|
10
|
+
& Animals\",\"type\":\"string\"}]},{\"external_id\":\"XfY9Dsg_DZk\",\"fields\":[{\"name\":\"url\",\"value\":\"http://www.youtube.com/watch?v=XfY9Dsg_DZk\",\"type\":\"enum\"},{\"name\":\"thumbnail_url\",\"value\":\"https://i.ytimg.com/vi/XfY9Dsg_DZk/mqdefault.jpg\",\"type\":\"enum\"},{\"name\":\"channel_id\",\"value\":\"UC5VA5j05FjETg-iLekcyiBw\",\"type\":\"enum\"},{\"name\":\"title\",\"value\":\"Corgi
|
11
|
+
talks to cat\",\"type\":\"string\"},{\"name\":\"category_name\",\"value\":\"Pets
|
12
|
+
& Animals\",\"type\":\"string\"}]}]}"
|
13
|
+
headers:
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
User-Agent:
|
19
|
+
- Swiftype-Ruby/1.0.1
|
20
|
+
Content-Type:
|
21
|
+
- application/json
|
22
|
+
response:
|
23
|
+
status:
|
24
|
+
code: 200
|
25
|
+
message: OK
|
26
|
+
headers:
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
X-Ua-Compatible:
|
30
|
+
- IE=Edge
|
31
|
+
Etag:
|
32
|
+
- "\"bb009c6dcb5c622766ad5aa1ea1562d9\""
|
33
|
+
Cache-Control:
|
34
|
+
- max-age=0, private, must-revalidate
|
35
|
+
Set-Cookie:
|
36
|
+
- _st_main_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJWZmYjQwMDY5M2RlZjFiNzk5NDkyNGVlYmY5MWRlODFlBjsAVEkiGXdhcmRlbi51c2VyLnJvbGUua2V5BjsAVFsISSIJUm9sZQY7AEZbBlU6Gk1vcGVkOjpCU09OOjpPYmplY3RJZCIRUscPIjrnQFhtAAADMA%3D%3D--1b489621236a6a65bd84a0e24987078b09db855e;
|
37
|
+
path=/; HttpOnly
|
38
|
+
X-Request-Id:
|
39
|
+
- 8f984b0c4a86889b38527cde5b3cdf47
|
40
|
+
X-Runtime:
|
41
|
+
- '0.034945'
|
42
|
+
Connection:
|
43
|
+
- close
|
44
|
+
Server:
|
45
|
+
- thin 1.5.0 codename Knife
|
46
|
+
body:
|
47
|
+
encoding: UTF-8
|
48
|
+
string: "[true,true]"
|
49
|
+
http_version:
|
50
|
+
recorded_at: Thu, 16 Jan 2014 23:13:08 GMT
|
51
|
+
recorded_with: VCR 2.8.0
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swiftype
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Quin Hoxie
|
@@ -10,70 +9,62 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2014-01-16 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: rspec
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - ">="
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: '0'
|
23
21
|
type: :development
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - ">="
|
29
26
|
- !ruby/object:Gem::Version
|
30
27
|
version: '0'
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: awesome_print
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- -
|
32
|
+
- - ">="
|
37
33
|
- !ruby/object:Gem::Version
|
38
34
|
version: '0'
|
39
35
|
type: :development
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- -
|
39
|
+
- - ">="
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: '0'
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: vcr
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
|
-
- -
|
46
|
+
- - ">="
|
53
47
|
- !ruby/object:Gem::Version
|
54
48
|
version: '0'
|
55
49
|
type: :development
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
|
-
- -
|
53
|
+
- - ">="
|
61
54
|
- !ruby/object:Gem::Version
|
62
55
|
version: '0'
|
63
56
|
- !ruby/object:Gem::Dependency
|
64
57
|
name: webmock
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
59
|
requirements:
|
68
|
-
- -
|
60
|
+
- - ">="
|
69
61
|
- !ruby/object:Gem::Version
|
70
62
|
version: '0'
|
71
63
|
type: :development
|
72
64
|
prerelease: false
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
66
|
requirements:
|
76
|
-
- -
|
67
|
+
- - ">="
|
77
68
|
- !ruby/object:Gem::Version
|
78
69
|
version: '0'
|
79
70
|
description: API client for accessing the Swiftype Search API with no dependencies
|
@@ -84,8 +75,8 @@ executables: []
|
|
84
75
|
extensions: []
|
85
76
|
extra_rdoc_files: []
|
86
77
|
files:
|
87
|
-
- .gitignore
|
88
|
-
- .travis.yml
|
78
|
+
- ".gitignore"
|
79
|
+
- ".travis.yml"
|
89
80
|
- Gemfile
|
90
81
|
- LICENSE.txt
|
91
82
|
- README.md
|
@@ -123,6 +114,8 @@ files:
|
|
123
114
|
- spec/fixtures/vcr/bulk_create_documents.yml
|
124
115
|
- spec/fixtures/vcr/bulk_create_or_update_documents_failure.yml
|
125
116
|
- spec/fixtures/vcr/bulk_create_or_update_documents_success.yml
|
117
|
+
- spec/fixtures/vcr/bulk_create_or_update_documents_verbose_failure.yml
|
118
|
+
- spec/fixtures/vcr/bulk_create_or_update_documents_verbose_success.yml
|
126
119
|
- spec/fixtures/vcr/bulk_destroy_documents.yml
|
127
120
|
- spec/fixtures/vcr/crawl_url.yml
|
128
121
|
- spec/fixtures/vcr/create_document.yml
|
@@ -177,27 +170,26 @@ files:
|
|
177
170
|
- swiftype.gemspec
|
178
171
|
homepage: https://swiftype.com
|
179
172
|
licenses: []
|
173
|
+
metadata: {}
|
180
174
|
post_install_message:
|
181
175
|
rdoc_options: []
|
182
176
|
require_paths:
|
183
177
|
- lib
|
184
178
|
required_ruby_version: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
179
|
requirements:
|
187
|
-
- -
|
180
|
+
- - ">="
|
188
181
|
- !ruby/object:Gem::Version
|
189
182
|
version: '0'
|
190
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
-
none: false
|
192
184
|
requirements:
|
193
|
-
- -
|
185
|
+
- - ">="
|
194
186
|
- !ruby/object:Gem::Version
|
195
187
|
version: '0'
|
196
188
|
requirements: []
|
197
189
|
rubyforge_project:
|
198
|
-
rubygems_version:
|
190
|
+
rubygems_version: 2.2.0
|
199
191
|
signing_key:
|
200
|
-
specification_version:
|
192
|
+
specification_version: 4
|
201
193
|
summary: Official gem for accessing the Swiftype Search API
|
202
194
|
test_files:
|
203
195
|
- spec/client_spec.rb
|
@@ -223,6 +215,8 @@ test_files:
|
|
223
215
|
- spec/fixtures/vcr/bulk_create_documents.yml
|
224
216
|
- spec/fixtures/vcr/bulk_create_or_update_documents_failure.yml
|
225
217
|
- spec/fixtures/vcr/bulk_create_or_update_documents_success.yml
|
218
|
+
- spec/fixtures/vcr/bulk_create_or_update_documents_verbose_failure.yml
|
219
|
+
- spec/fixtures/vcr/bulk_create_or_update_documents_verbose_success.yml
|
226
220
|
- spec/fixtures/vcr/bulk_destroy_documents.yml
|
227
221
|
- spec/fixtures/vcr/crawl_url.yml
|
228
222
|
- spec/fixtures/vcr/create_document.yml
|
@@ -274,4 +268,3 @@ test_files:
|
|
274
268
|
- spec/spec_helper.rb
|
275
269
|
- spec/ssl_spec.rb
|
276
270
|
- spec/sso_spec.rb
|
277
|
-
has_rdoc:
|