NAME

Data::AnyXfer::Elastic::Utils - Utility methods for Elasticsearch Modules

SYNOPSIS

use aliased 'Data::AnyXfer::Elastic::Utils';
Utils->_configure_name('interiors');

DESCRIPTION

This module provides utility methods to be used within Data::AnyXfer::Elastic.

METHODS

configure_index_name

$name = Utils->configure_index_name('interiors');
$names = Utils->configure_index_name(['interiors', 'properties']);
print $name;    # prints e.g. interiors_20141230120001

# or under test...
print $name;    # prints e.g. <user>_<hostname>_<package>_interiors_20141230120001

If being executued within a test environment, the index name is made unique enough to prevent clashes.

configure_alias_name

$name = Utils->configure_alias_name('interiors');
$names = Utils->configure_alias_name(['interiors', 'properties']);
print $name;    # prints e.g. <user>_<hostname>_<package>_interiors.

If being executued within a test environment, the alias name is made unique enough to prevent clashes.

wait_for_doc_count

$_->index(@documents) foreach @{$clients};

$class->wait_for_doc_count(
    target_doc_count => scalar @documents,
    index_name => 'interiors',
    clients => [@clients],
    timeout => 600);

print "All documents indexed!\n";

Waits for the number of documents visible within an Elasticsearch index to reach or exceed a desired number. This is useful to synchronise code, so that we do not continue until an index is ready.

Takes the following named arguments:

target_doc_count

The target number of documents expected to be available on the index.

index_name

The index or alias name to check

clients

An ARRAY ref containing one of more Search::Elasticsearch clients or Data::AnyXfer::Elastic::Index instances.

timeout

The number of seconds to wait until we give up. Defaults to 20.

Returns 1 on success, otherwise dies.

COPYRIGHT

This software is copyright (c) 2019, Anthony Lucas.

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