8.12 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform
Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.
Apache-2.0 - Apache License 2.0Search::Elasticsearch is the official Perl API for Elasticsearch. The full documentation is available on https://metacpan.org/module/Search::Elasticsearch.
Log::Any
cpanm Search::Elasticsearch
You can connect to Elasticsearch using the following examples:
use Search::Elasticsearch;
# Connect to localhost:9200 (default)
my $e = Search::Elasticsearch->new();
# Connect to http://search:9200
my $e = Search::Elasticsearch->new(
nodes => [ 'search:9200' ]
);
# Round-robin between two nodes:
my $e = Search::Elasticsearch->new(
nodes => [
'search1:9200',
'search2:9200'
]
);
After the connection you can start using the Elaticsearch endpoints
as functions of $e
object, as follows:
# Info endpoint
my $result = $e->info();
printf("Name: %s\n", $result->{name}); # e.g. Name: instance-001
printf("Version: %s\n", $result->{version}->{number}); # e.g. Version: 8.5.2
Elastic Cloud is the cloud solution offered by Elastic.
To connect the Perl client to Elastic Cloud you need the get the following data:
You can retrieve these data from your Elastic Cloud dashboard. You need to open the Manage Deployments page and Copy endpoint of Elasticsearch (see screenshot below).
This endpoint is the server address of Test instance (e.g. https://my-test.es.us-central1.gcp.cloud.es.io).
After this step, you need to generate an API key
in the Management
page under the section Security
.
When you click on Create API key
button you can choose a name and set the
other options (for example, restrict privileges, expire after time, and so on).
After this step you will get the API key
in the API keys page.
IMPORTANT: you need to copy and store the API key
in a secure place, since
you will not be able to view it again in Elastic Cloud.
Finally, you can use the Elasticsearch endpoint and the API Key for connecting the Perl client as follows:
my $e = Search::Elasticsearch->new(
nodes => [ 'https://my-test.es.us-central1.gcp.cloud.es.io' ],
elastic_cloud_api_key => 'insert here the API Key'
);
Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of Elasticsearch. Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made.
This software is licensed under the Apache 2 license.