
ElasticSearchX::Model::Bulk

version 0.1.6

my $bulk = $model->bulk( size => 10 );
my $document = $model->index('default')->type('tweet')->new_document({
message => 'Hello there!',
date => DateTime->now,
});
$bulk->put( $document );
$bulk->commit;

This class is a wrapper around "bulk()" in ElasticSearch which adds some convenience. By specifiying a "size" you set the maximum number of documents that are processed in one request. You can either "put" or "delete" documents. Once the $bulk object is out of scope, it will automatically commit its "stash". Call "clear" if before if you don't want that to happen.

The maximum number of documents that are processed in one request. Once the stash hits that number, a bulk request will be issued automatically and the stash will be cleared.
The stash includes the documents that will be processed at the next commit. A commit is either automatically issued if the size of the stash is greater then "size", if the $bulk object gets out of scope or if you call "commit" explicitly.
The ElasticSearch object.

Put a document. Accepts a document object (see "new_document" in ElasticSearchX::Model::Document::Set) or a HashRef for better performance.
Delete a document. You can either pass a document object or a HashRef that consists of index, type and id.
Commits the documents in the stash to ElasticSearch.
Clears the stash.
Returns the number of documents in the stash.

Moritz Onken

This software is Copyright (c) 2013 by Moritz Onken.
This is free software, licensed under:
The (three-clause) BSD License