NAME

Elastic::Model::Role::Store - Elasticsearch backend for document read/write requests

VERSION

version 0.29_2

DESCRIPTION

All document-related requests to the Elasticsearch backend are handled via Elastic::Model::Role::Store.

ATTRIBUTES

es

$es = $store->es

Returns the connection to Elasticsearch.

METHODS

get_doc()

$result = $store->get_doc($uid, %args);

Retrieves the doc specified by the $uid from Elasticsearch, by calling "get()" in Search::Elasticsearch::Compat. Throws an exception if the document does not exist.

doc_exists()

$bool = $store->doc_exists($uid, %args);

Checks whether the doc exists in ElastciSearch. Any %args are passed through to "exists()" in Search::Elasticsearch::Compat.

create_doc()

$result = $store->create_doc($uid => \%data, %args);

Creates a doc in the Elasticsearch backend and returns the raw result. Throws an exception if a doc with the same $uid already exists. Any %args are passed to "create()" in Search::Elasticsearch::Compat

index_doc()

$result = $store->index_doc($uid => \%data, %args);

Updates (or creates) a doc in the Elasticsearch backend and returns the raw result. Any failure throws an exception. If the version number does not match what is stored in Elasticsearch, then a conflict exception will be thrown. Any %args will be passed to "index()" in Search::Elasticsearch::Compat. For instance, to overwrite a document regardless of version number, you could do:

$result = $store->index_doc($uid => \%data, version => 0 );

delete_doc()

$result = $store->delete_doc($uid, %args);

Deletes a doc in the Elasticsearch backend and returns the raw result. Any failure throws an exception. If the version number does not match what is stored in Elasticsearch, then a conflict exception will be thrown. Any %args will be passed to "delete()" in Search::Elasticsearch::Compat.

bulk()

$result = $store->bulk(
    actions     => $actions,
    on_conflict => sub {...},
    on_error    => sub {...},
    %args
);

Performs several actions in a single request. Any %agrs will be passed to "bulk()" in Search::Elasticsearch::Compat.

search()

$results = $store->search(@args);

Performs a search, passing @args to "search()" in Search::Elasticsearch::Compat.

scrolled_search()

$results = $store->scrolled_search(@args);

Performs a scrolled search, passing @args to "scrolled_search()" in Search::Elasticsearch::Compat.

AUTHOR

Clinton Gormley <drtech@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Clinton Gormley.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.