2013-10-15 11:22:21 -04:00
|
|
|
= Elasticsearch.pm
|
|
|
|
|
|
|
|
== Overview
|
|
|
|
|
|
|
|
Elasticsearch.pm is the official Perl API for Elasticsearch. The full
|
2013-10-15 11:27:05 -04:00
|
|
|
documentation is available on https://metacpan.org/module/Elasticsearch.
|
|
|
|
|
|
|
|
It can be installed with:
|
2013-10-15 11:22:21 -04:00
|
|
|
|
|
|
|
[source,sh]
|
|
|
|
------------------------------------
|
|
|
|
cpanm Elasticsearch
|
|
|
|
------------------------------------
|
|
|
|
|
|
|
|
=== Features
|
|
|
|
|
|
|
|
This client provides:
|
|
|
|
|
|
|
|
* Full support for all Elasticsearch APIs
|
|
|
|
|
|
|
|
* HTTP backend (currently synchronous only - Any::Event support will be added later)
|
|
|
|
|
|
|
|
* Robust networking support which handles load balancing, failure detection and failover
|
|
|
|
|
|
|
|
* Good defaults
|
|
|
|
|
|
|
|
* Helper utilities for more complex operations, such as bulk indexing, scrolled searches and reindexing.
|
|
|
|
|
|
|
|
* Logging support via Log::Any
|
|
|
|
|
|
|
|
* Compatibility with the official clients for Python, Ruby, PHP and Javascript
|
|
|
|
|
|
|
|
* Easy extensibility
|
|
|
|
|
|
|
|
== Synopsis
|
|
|
|
|
|
|
|
[source,perl]
|
|
|
|
------------------------------------
|
|
|
|
use Elasticsearch;
|
|
|
|
|
|
|
|
# Connect to localhost:9200:
|
|
|
|
my $e = Elasticsearch->new();
|
|
|
|
|
|
|
|
# Round-robin between two nodes:
|
|
|
|
my $e = Elasticsearch->new(
|
|
|
|
nodes => [
|
|
|
|
'search1:9200',
|
|
|
|
'search2:9200'
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
# Connect to cluster at search1:9200, sniff all nodes and round-robin between them:
|
|
|
|
my $e = Elasticsearch->new(
|
|
|
|
nodes => 'search1:9200',
|
|
|
|
cxn_pool => 'Sniff'
|
|
|
|
);
|
|
|
|
|
|
|
|
# Index a document:
|
|
|
|
$e->index(
|
|
|
|
index => 'my_app',
|
|
|
|
type => 'blog_post',
|
|
|
|
id => 1,
|
|
|
|
body => {
|
|
|
|
title => 'Elasticsearch clients',
|
|
|
|
content => 'Interesting content...',
|
|
|
|
date => '2013-09-24'
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
# Get the document:
|
|
|
|
my $doc = $e->get(
|
|
|
|
index => 'my_app',
|
|
|
|
type => 'blog_post',
|
|
|
|
id => 1
|
|
|
|
);
|
|
|
|
|
|
|
|
# Search:
|
|
|
|
my $results = $e->search(
|
|
|
|
index => 'my_app',
|
|
|
|
body => {
|
|
|
|
query => {
|
|
|
|
match => { title => 'elasticsearch' }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
------------------------------------
|
|
|
|
|
|
|
|
== Reporting issues
|
|
|
|
|
|
|
|
The GitHub repository is http://github.com/elasticsearch/elasticsearch-perl
|
|
|
|
and any issues can be reported on the issues list at
|
|
|
|
http://github.com/elasticsearch/elasticsearch-perl/issues.
|
|
|
|
|
|
|
|
== Contributing
|
|
|
|
|
|
|
|
Open source contributions are welcome. Please read our
|
|
|
|
https://github.com/elasticsearch/elasticsearch-perl/blob/master/CONTRIBUTING.asciidoc[guide to contributing].
|
|
|
|
|
|
|
|
== Copyright and License
|
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Elasticsearch BV.
|
|
|
|
|
|
|
|
This is free software, licensed under:
|
|
|
|
https://github.com/elasticsearch/elasticsearch-perl/blob/master/LICENSE.txt[The Apache License Version 2.0].
|
|
|
|
|
|
|
|
|
|
|
|
|