++ed by:
PERLER PLU ABRAXXA

3 PAUSE users
1 non-PAUSE user.

Olaf Alders 🐫
and 4 contributors

NAME

ElasticSearchX::Model::Bulk

VERSION

version 0.2.2

SYNOPSIS

 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;

DESCRIPTION

This class is a wrapper around Search::Elasticsearch::Bulk 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.

ATTRIBUTES

size

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.

stash

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.

es

The Search::Elasticsearch object.

METHODS

create

update

put( $doc )

put( $doc, { %qs } )

Put a document. Accepts a document object (see "new_document" in ElasticSearchX::Model::Document::Set) or a HashRef for better performance.

delete

Delete a document. You can either pass a document object or a HashRef that consists of index, type and id.

commit

Commits the documents in the stash to ElasticSearch.

clear

Clears the stash.

stash_size

Returns the number of documents in the stash.

AUTHOR

Moritz Onken

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by Moritz Onken.

This is free software, licensed under:

  The (three-clause) BSD License