algoliasearch 1.16.0 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +3 -0
- data/lib/algolia/index.rb +23 -0
- data/lib/algolia/protocol.rb +4 -0
- data/lib/algolia/version.rb +1 -1
- data/spec/client_spec.rb +25 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b003d66ce48ed84c00beee6a9e93bb65c704ca2e
|
4
|
+
data.tar.gz: f9ae3ed72cd92b351684a22b45ef9ccd2f486fc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e72ac4175524739045f3fdb369f2e65c29714744c63af237542f0f7086b2ec6acd19aa17736793bdf28a1e545488005724ce3d6437560a73175c06bc712aa20a
|
7
|
+
data.tar.gz: 3aa8a7e84b25d0487ac8cb7c6545c26b79fb5fa5b5b78f80e146c54cb0897457880cb68b834afd9a5f5e1239763a7b33c874e965e73b54d4736e4b3a21259ad0
|
data/ChangeLog
CHANGED
data/lib/algolia/index.rb
CHANGED
@@ -434,6 +434,29 @@ module Algolia
|
|
434
434
|
res
|
435
435
|
end
|
436
436
|
|
437
|
+
#
|
438
|
+
# Delete all objects matching a query (doesn't work with actual text queries)
|
439
|
+
# This method deletes every record matching the filters provided
|
440
|
+
#
|
441
|
+
# @param params query parameters
|
442
|
+
#
|
443
|
+
def delete_by(params)
|
444
|
+
raise ArgumentError.new('params cannot be nil, use the `clear` method to wipe the entire index') if params.nil?
|
445
|
+
params = sanitized_delete_by_query_params(params)
|
446
|
+
client.post(Protocol.delete_by_uri(name), params.to_json)
|
447
|
+
end
|
448
|
+
|
449
|
+
#
|
450
|
+
# Delete all objects matching a query (doesn't work with actual text queries)
|
451
|
+
# This method deletes every record matching the filters provided and waits for the end of indexing
|
452
|
+
# @param params query parameters
|
453
|
+
#
|
454
|
+
def delete_by!(params)
|
455
|
+
res = delete_by(params)
|
456
|
+
wait_task(res['taskID']) if res
|
457
|
+
res
|
458
|
+
end
|
459
|
+
|
437
460
|
#
|
438
461
|
# Delete the index content
|
439
462
|
#
|
data/lib/algolia/protocol.rb
CHANGED
data/lib/algolia/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -249,6 +249,31 @@ describe 'Client' do
|
|
249
249
|
expect { @index.delete_by_query(nil) }.to raise_error(ArgumentError)
|
250
250
|
end
|
251
251
|
|
252
|
+
context 'delete_by' do
|
253
|
+
it 'should not wipe the entire index' do
|
254
|
+
expect { @index.delete_by(nil) }.to raise_error(ArgumentError)
|
255
|
+
end
|
256
|
+
|
257
|
+
it 'should fail with query passed' do
|
258
|
+
@index.clear
|
259
|
+
@index.add_object({:firstname => 'Robert1'})
|
260
|
+
@index.add_object!({:firstname => 'Robert2'})
|
261
|
+
@index.search('')['nbHits'].should eq(2)
|
262
|
+
expect { @index.delete_by({ 'query' => 'abc' }) }.to raise_error(Algolia::AlgoliaProtocolError)
|
263
|
+
@index.search('')['nbHits'].should eq(2)
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'should work with filters' do
|
267
|
+
@index.clear
|
268
|
+
@index.set_settings!({:attributesForFaceting => ['firstname']})
|
269
|
+
@index.add_object({:firstname => 'Robert1'})
|
270
|
+
@index.add_object!({:firstname => 'Robert2'})
|
271
|
+
@index.search('')['nbHits'].should eq(2)
|
272
|
+
@index.delete_by!({ 'filters' => 'firstname:Robert1' })
|
273
|
+
@index.search('')['nbHits'].should eq(1)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
252
277
|
it "should copy the index" do
|
253
278
|
index = Algolia::Index.new(safe_index_name("àlgol?à"))
|
254
279
|
begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.6.
|
134
|
+
rubygems_version: 2.6.10
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: A simple Ruby client for the algolia.com REST API
|