2013-10-15 11:22:21 -04:00
|
|
|
= Elasticsearch.pm
|
|
|
|
|
|
|
|
== Overview
|
|
|
|
|
2014-03-09 14:45:16 -04:00
|
|
|
Search::Elasticsearch is the official Perl API for Elasticsearch. The full
|
|
|
|
documentation is available on https://metacpan.org/module/Search::Elasticsearch.
|
2013-10-15 11:27:05 -04:00
|
|
|
|
|
|
|
It can be installed with:
|
2013-10-15 11:22:21 -04:00
|
|
|
|
|
|
|
[source,sh]
|
|
|
|
------------------------------------
|
2014-03-09 14:45:16 -04:00
|
|
|
cpanm Search::Elasticsearch
|
2013-10-15 11:22:21 -04:00
|
|
|
------------------------------------
|
|
|
|
|
|
|
|
=== Features
|
|
|
|
|
|
|
|
This client provides:
|
|
|
|
|
|
|
|
* Full support for all Elasticsearch APIs
|
|
|
|
|
2014-10-29 09:48:56 -04:00
|
|
|
* HTTP backend (blocking and asynchronous with https://metacpan.org/module/Search::Elasticsearch::Async)
|
2013-10-15 11:22:21 -04:00
|
|
|
|
|
|
|
* 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]
|
|
|
|
------------------------------------
|
2014-03-09 14:45:16 -04:00
|
|
|
use Search::Elasticsearch;
|
2013-10-15 11:22:21 -04:00
|
|
|
|
|
|
|
# Connect to localhost:9200:
|
2014-03-09 14:45:16 -04:00
|
|
|
my $e = Search::Elasticsearch->new();
|
2013-10-15 11:22:21 -04:00
|
|
|
|
|
|
|
# Round-robin between two nodes:
|
2014-03-09 14:45:16 -04:00
|
|
|
my $e = Search::Elasticsearch->new(
|
2013-10-15 11:22:21 -04:00
|
|
|
nodes => [
|
|
|
|
'search1:9200',
|
|
|
|
'search2:9200'
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
# Connect to cluster at search1:9200, sniff all nodes and round-robin between them:
|
2014-03-09 14:45:16 -04:00
|
|
|
my $e = Search::Elasticsearch->new(
|
2013-10-15 11:22:21 -04:00
|
|
|
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...',
|
2015-02-28 11:19:55 -05:00
|
|
|
date => '2014-09-24'
|
2013-10-15 11:22:21 -04:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
# 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' }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
------------------------------------
|
|
|
|
|
2014-02-06 13:10:39 -05:00
|
|
|
[[v0_90]]
|
|
|
|
== Elasticsearch 0.90.* and earlier
|
|
|
|
|
|
|
|
The current version of the client supports the Elasticsearch 1.0 branch by
|
|
|
|
default, which is not backwards compatible with the 0.90 branch.
|
|
|
|
|
|
|
|
If you need to talk to a version of Elasticsearch before 1.0.0,
|
2014-03-09 14:45:16 -04:00
|
|
|
please use `Search::Elasticsearch::Client::0_90::Direct` as follows:
|
2014-02-06 13:10:39 -05:00
|
|
|
|
|
|
|
[source,perl]
|
|
|
|
------------------------------------
|
2014-03-09 14:45:16 -04:00
|
|
|
$es = Search::Elasticsearch->new(
|
2014-02-06 13:10:39 -05:00
|
|
|
client => '0_90::Direct'
|
|
|
|
);
|
|
|
|
------------------------------------
|
|
|
|
|
|
|
|
|
2013-10-15 11:22:21 -04:00
|
|
|
== Reporting issues
|
|
|
|
|
2016-03-03 14:03:05 -05:00
|
|
|
The GitHub repository is https://github.com/elastic/elasticsearch-perl
|
2013-10-15 11:22:21 -04:00
|
|
|
and any issues can be reported on the issues list at
|
2016-03-03 14:03:05 -05:00
|
|
|
https://github.com/elastic/elasticsearch-perl/issues.
|
2013-10-15 11:22:21 -04:00
|
|
|
|
|
|
|
== Contributing
|
|
|
|
|
|
|
|
Open source contributions are welcome. Please read our
|
2016-03-03 14:03:05 -05:00
|
|
|
https://github.com/elastic/elasticsearch-perl/blob/master/CONTRIBUTING.asciidoc[guide to contributing].
|
2013-10-15 11:22:21 -04:00
|
|
|
|
|
|
|
== Copyright and License
|
|
|
|
|
2016-04-18 06:39:23 -04:00
|
|
|
This software is Copyright (c) 2013-2016 by Elasticsearch BV.
|
2013-10-15 11:22:21 -04:00
|
|
|
|
|
|
|
This is free software, licensed under:
|
2016-03-03 14:03:05 -05:00
|
|
|
https://github.com/elastic/elasticsearch-perl/blob/master/LICENSE.txt[The Apache License Version 2.0].
|
2013-10-15 11:22:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|