NAME

ElasticSearchX::Model::Bulk

VERSION

version 0.1.7

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 "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.

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 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) 2013 by Moritz Onken.

This is free software, licensed under:

The (three-clause) BSD License