search_flip 4.0.0.beta10 → 4.0.0.beta11
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/search_flip/connection.rb +45 -0
- data/lib/search_flip/index.rb +1 -1
- data/lib/search_flip/version.rb +1 -1
- data/search_flip.gemspec +0 -1
- data/spec/search_flip/connection_spec.rb +90 -0
- data/spec/spec_helper.rb +2 -0
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e032e109a7c31df14182c17d874f793327081c3c4e5b866dbfb261e8aa4e503
|
4
|
+
data.tar.gz: 73a2ce2eb918e9f3da28f3bf129eb614c1da5492d138985732af4b41a9f15a41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 152130c3a91ae69dcf53ff43534b0b853786900f1c03847ffead4d52254f95aec5dbfb48362d6386a61fdb92f128b68fc22b2b66f4df27f2a099a9d6db356eea
|
7
|
+
data.tar.gz: '09f13f81114378ebd9dea98ae713f5be8a27dea15966bf2fc05195900be8ed74c73d6aa46d6a458a4d4aaeb8467e32cc4296fce4e22dbfee672a1dc30d4af14f'
|
data/CHANGELOG.md
CHANGED
@@ -11,6 +11,11 @@
|
|
11
11
|
* Added `SearchFlip::Connection#get_cluster_settings` and
|
12
12
|
`#update_cluster_settings`
|
13
13
|
|
14
|
+
## v3.7.0
|
15
|
+
|
16
|
+
* Add `SearchFlip::Connection#bulk` to allow more clean bulk indexing to
|
17
|
+
multiple indices at once
|
18
|
+
|
14
19
|
## v3.6.0
|
15
20
|
|
16
21
|
* Support Elasticsearch v8
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
Using SearchFlip it is dead-simple to create index classes that correspond to
|
10
10
|
[Elasticsearch](https://www.elastic.co/) indices and to manipulate, query and
|
11
11
|
aggregate these indices using a chainable, concise, yet powerful DSL. Finally,
|
12
|
-
SearchFlip supports Elasticsearch 2.x, 5.x, 6.x, 7.x. Check section
|
12
|
+
SearchFlip supports Elasticsearch 2.x, 5.x, 6.x, 7.x and 8.x. Check section
|
13
13
|
[Feature Support](#feature-support) for version dependent features.
|
14
14
|
|
15
15
|
```ruby
|
@@ -384,6 +384,51 @@ module SearchFlip
|
|
384
384
|
raise e
|
385
385
|
end
|
386
386
|
|
387
|
+
# Initiates and yields a bulk object, such that index, import, create,
|
388
|
+
# update and delete requests can be appended to the bulk request. Please
|
389
|
+
# note that you need to manually pass the desired index name as well as
|
390
|
+
# type name (depending on the Elasticsearch version) when using #bulk on a
|
391
|
+
# connection object or Elasticsearch will return an error. After the bulk
|
392
|
+
# requests are successfully processed all existing indices will
|
393
|
+
# subsequently be refreshed when auto_refresh is enabled.
|
394
|
+
#
|
395
|
+
# @see SearchFlip::Config See SearchFlip::Config for auto_refresh
|
396
|
+
#
|
397
|
+
# @example
|
398
|
+
# connection = SearchFlip::Connection.new
|
399
|
+
#
|
400
|
+
# connection.bulk ignore_errors: [409] do |bulk|
|
401
|
+
# bulk.create comment.id, CommentIndex.serialize(comment),
|
402
|
+
# _index: CommentIndex.index_name, version: comment.version, version_type: "external_gte"
|
403
|
+
#
|
404
|
+
# bulk.delete product.id, _index: ProductIndex.index_name, routing: product.user_id
|
405
|
+
#
|
406
|
+
# # ...
|
407
|
+
# end
|
408
|
+
#
|
409
|
+
# @param options [Hash] Specifies options regarding the bulk indexing
|
410
|
+
# @option options ignore_errors [Array] Specifies an array of http status
|
411
|
+
# codes that shouldn't raise any exceptions, like eg 409 for conflicts,
|
412
|
+
# ie when optimistic concurrency control is used.
|
413
|
+
# @option options raise [Boolean] Prevents any exceptions from being
|
414
|
+
# raised. Please note that this only applies to the bulk response, not to
|
415
|
+
# the request in general, such that connection errors, etc will still
|
416
|
+
# raise.
|
417
|
+
|
418
|
+
def bulk(options = {})
|
419
|
+
default_options = {
|
420
|
+
http_client: http_client,
|
421
|
+
bulk_limit: bulk_limit,
|
422
|
+
bulk_max_mb: bulk_max_mb
|
423
|
+
}
|
424
|
+
|
425
|
+
SearchFlip::Bulk.new("#{base_url}/_bulk", default_options.merge(options)) do |indexer|
|
426
|
+
yield indexer
|
427
|
+
end
|
428
|
+
|
429
|
+
refresh if SearchFlip::Config[:auto_refresh]
|
430
|
+
end
|
431
|
+
|
387
432
|
# Returns the full Elasticsearch type URL, ie base URL, index name with
|
388
433
|
# prefix and type name.
|
389
434
|
#
|
data/lib/search_flip/index.rb
CHANGED
@@ -601,7 +601,7 @@ module SearchFlip
|
|
601
601
|
scope
|
602
602
|
end
|
603
603
|
|
604
|
-
# Initiates and yields
|
604
|
+
# Initiates and yields a bulk object, such that index, import, create,
|
605
605
|
# update and delete requests can be appended to the bulk request. Sends a
|
606
606
|
# refresh request afterwards if auto_refresh is enabled.
|
607
607
|
#
|
data/lib/search_flip/version.rb
CHANGED
data/search_flip.gemspec
CHANGED
@@ -15,7 +15,6 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
18
|
spec.require_paths = ["lib"]
|
20
19
|
|
21
20
|
spec.post_install_message = <<~MESSAGE
|
@@ -344,6 +344,96 @@ RSpec.describe SearchFlip::Connection do
|
|
344
344
|
end
|
345
345
|
end
|
346
346
|
|
347
|
+
describe "#bulk" do
|
348
|
+
it "imports objects to the specified indices" do
|
349
|
+
connection = SearchFlip::Connection.new
|
350
|
+
|
351
|
+
bulk = proc do
|
352
|
+
connection.bulk do |indexer|
|
353
|
+
indexer.index 1, { id: 1 }, _index: ProductIndex.index_name, ** connection.version.to_i < 8 ? { _type: ProductIndex.type_name } : {}
|
354
|
+
indexer.index 2, { id: 2 }, _index: ProductIndex.index_name, ** connection.version.to_i < 8 ? { _type: ProductIndex.type_name } : {}
|
355
|
+
indexer.index 1, { id: 1 }, _index: CommentIndex.index_name, ** connection.version.to_i < 8 ? { _type: CommentIndex.type_name } : {}
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
expect(&bulk).to(change { CommentIndex.total_count }.by(1).and(change { CommentIndex.total_count }.by(1)))
|
360
|
+
end
|
361
|
+
|
362
|
+
it "raises when no index is given" do
|
363
|
+
connection = SearchFlip::Connection.new
|
364
|
+
|
365
|
+
bulk = proc do
|
366
|
+
connection.bulk do |indexer|
|
367
|
+
indexer.index 1, id: 1
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
expect(&bulk).to raise_error(SearchFlip::ResponseError)
|
372
|
+
end
|
373
|
+
|
374
|
+
it "respects options" do
|
375
|
+
connection = SearchFlip::Connection.new
|
376
|
+
|
377
|
+
connection.bulk do |indexer|
|
378
|
+
indexer.index 1, { id: 1 }, _index: ProductIndex.index_name, ** connection.version.to_i < 8 ? { _type: ProductIndex.type_name } : {}
|
379
|
+
indexer.index 2, { id: 2 }, _index: ProductIndex.index_name, ** connection.version.to_i < 8 ? { _type: ProductIndex.type_name } : {}
|
380
|
+
end
|
381
|
+
|
382
|
+
bulk = proc do
|
383
|
+
connection.bulk do |indexer|
|
384
|
+
indexer.index 1, { id: 1 }, _index: ProductIndex.index_name, version: 1, version_type: "external", ** connection.version.to_i < 8 ? { _type: ProductIndex.type_name } : {}
|
385
|
+
indexer.index 2, { id: 2 }, _index: ProductIndex.index_name, version: 1, version_type: "external", ** connection.version.to_i < 8 ? { _type: ProductIndex.type_name } : {}
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
expect(&bulk).to raise_error(SearchFlip::Bulk::Error)
|
390
|
+
|
391
|
+
bulk = proc do
|
392
|
+
connection.bulk ignore_errors: [409] do |indexer|
|
393
|
+
indexer.index 1, { id: 1 }, _index: ProductIndex.index_name, version: 1, version_type: "external", ** connection.version.to_i < 8 ? { _type: ProductIndex.type_name } : {}
|
394
|
+
indexer.index 2, { id: 2 }, _index: ProductIndex.index_name, version: 1, version_type: "external", ** connection.version.to_i < 8 ? { _type: ProductIndex.type_name } : {}
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
expect(&bulk).not_to(change { ProductIndex.total_count })
|
399
|
+
end
|
400
|
+
|
401
|
+
it "passes default options" do
|
402
|
+
allow(SearchFlip::Bulk).to receive(:new)
|
403
|
+
|
404
|
+
connection = SearchFlip::Connection.new
|
405
|
+
|
406
|
+
connection.bulk do |indexer|
|
407
|
+
indexer.index 1, { id: 1 }, _index: ProductIndex.index_name, ** connection.version.to_i < 8 ? { _type: ProductIndex.type_name } : {}
|
408
|
+
end
|
409
|
+
|
410
|
+
expect(SearchFlip::Bulk).to have_received(:new).with(
|
411
|
+
anything,
|
412
|
+
http_client: connection.http_client,
|
413
|
+
bulk_limit: connection.bulk_limit,
|
414
|
+
bulk_max_mb: connection.bulk_max_mb
|
415
|
+
)
|
416
|
+
end
|
417
|
+
|
418
|
+
it "passes custom options" do
|
419
|
+
allow(SearchFlip::Bulk).to receive(:new)
|
420
|
+
|
421
|
+
connection = SearchFlip::Connection.new
|
422
|
+
|
423
|
+
options = {
|
424
|
+
bulk_limit: "bulk limit",
|
425
|
+
bulk_max_mb: "bulk max mb",
|
426
|
+
http_client: "http client"
|
427
|
+
}
|
428
|
+
|
429
|
+
connection.bulk(options) do |indexer|
|
430
|
+
indexer.index 1, { id: 1 }, _index: ProductIndex.index_name, ** connection.version.to_i < 8 ? { _type: ProductIndex.type_name } : {}
|
431
|
+
end
|
432
|
+
|
433
|
+
expect(SearchFlip::Bulk).to have_received(:new).with(anything, options)
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
347
437
|
describe "#index_url" do
|
348
438
|
it "returns the index url for the specified index" do
|
349
439
|
connection = SearchFlip::Connection.new(base_url: "base_url")
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: search_flip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.beta11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Vetter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -291,18 +291,4 @@ rubygems_version: 3.2.3
|
|
291
291
|
signing_key:
|
292
292
|
specification_version: 4
|
293
293
|
summary: Full-Featured Elasticsearch Ruby Client with a Chainable DSL
|
294
|
-
test_files:
|
295
|
-
- spec/delegate_matcher.rb
|
296
|
-
- spec/search_flip/aggregation_spec.rb
|
297
|
-
- spec/search_flip/aws_sigv4_plugin_spec.rb
|
298
|
-
- spec/search_flip/bulk_spec.rb
|
299
|
-
- spec/search_flip/connection_spec.rb
|
300
|
-
- spec/search_flip/criteria_spec.rb
|
301
|
-
- spec/search_flip/http_client_spec.rb
|
302
|
-
- spec/search_flip/index_spec.rb
|
303
|
-
- spec/search_flip/json_spec.rb
|
304
|
-
- spec/search_flip/model_spec.rb
|
305
|
-
- spec/search_flip/null_instrumenter_spec.rb
|
306
|
-
- spec/search_flip/response_spec.rb
|
307
|
-
- spec/search_flip/result_spec.rb
|
308
|
-
- spec/spec_helper.rb
|
294
|
+
test_files: []
|