index.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. = Elasticsearch.pm
  2. == Overview
  3. Search::Elasticsearch is the official Perl API for Elasticsearch. The full
  4. documentation is available on https://metacpan.org/module/Search::Elasticsearch.
  5. It can be installed with:
  6. [source,sh]
  7. ------------------------------------
  8. cpanm Search::Elasticsearch
  9. ------------------------------------
  10. === Features
  11. This client provides:
  12. * Full support for all Elasticsearch APIs
  13. * HTTP backend (blocking and asynchronous with https://metacpan.org/module/Search::Elasticsearch::Async)
  14. * Robust networking support which handles load balancing, failure detection and failover
  15. * Good defaults
  16. * Helper utilities for more complex operations, such as bulk indexing, scrolled searches and reindexing.
  17. * Logging support via Log::Any
  18. * Compatibility with the official clients for Python, Ruby, PHP and JavaScript
  19. * Easy extensibility
  20. == Synopsis
  21. [source,perl]
  22. ------------------------------------
  23. use Search::Elasticsearch;
  24. # Connect to localhost:9200:
  25. my $e = Search::Elasticsearch->new();
  26. # Round-robin between two nodes:
  27. my $e = Search::Elasticsearch->new(
  28. nodes => [
  29. 'search1:9200',
  30. 'search2:9200'
  31. ]
  32. );
  33. # Connect to cluster at search1:9200, sniff all nodes and round-robin between them:
  34. my $e = Search::Elasticsearch->new(
  35. nodes => 'search1:9200',
  36. cxn_pool => 'Sniff'
  37. );
  38. # Index a document:
  39. $e->index(
  40. index => 'my_app',
  41. type => 'blog_post',
  42. id => 1,
  43. body => {
  44. title => 'Elasticsearch clients',
  45. content => 'Interesting content...',
  46. date => '2014-09-24'
  47. }
  48. );
  49. # Get the document:
  50. my $doc = $e->get(
  51. index => 'my_app',
  52. type => 'blog_post',
  53. id => 1
  54. );
  55. # Search:
  56. my $results = $e->search(
  57. index => 'my_app',
  58. body => {
  59. query => {
  60. match => { title => 'elasticsearch' }
  61. }
  62. }
  63. );
  64. ------------------------------------
  65. [[v0_90]]
  66. == Elasticsearch 0.90.* and earlier
  67. The current version of the client supports the Elasticsearch 1.0 branch by
  68. default, which is not backwards compatible with the 0.90 branch.
  69. If you need to talk to a version of Elasticsearch before 1.0.0,
  70. please use `Search::Elasticsearch::Client::0_90::Direct` as follows:
  71. [source,perl]
  72. ------------------------------------
  73. $es = Search::Elasticsearch->new(
  74. client => '0_90::Direct'
  75. );
  76. ------------------------------------
  77. == Reporting issues
  78. The GitHub repository is https://github.com/elastic/elasticsearch-perl
  79. and any issues can be reported on the issues list at
  80. https://github.com/elastic/elasticsearch-perl/issues.
  81. == Contributing
  82. Open source contributions are welcome. Please read our
  83. https://github.com/elastic/elasticsearch-perl/blob/master/CONTRIBUTING.asciidoc[guide to contributing].
  84. == Copyright and License
  85. This software is Copyright (c) 2013-2018 by Elasticsearch BV.
  86. This is free software, licensed under:
  87. https://github.com/elastic/elasticsearch-perl/blob/master/LICENSE.txt[The Apache License Version 2.0].