This is an automated email from the git hooks/post-receive script.

drojf-guest pushed a commit to branch master
in repository libcatmandu-store-elasticsearch-perl.

commit b2b2048a10b8800c8dac74d64da145649abc5ffa
Author: Mirko Tietgen <mi...@abunchofthings.net>
Date:   Mon Mar 13 13:48:28 2017 +0100

    New upstream version 0.0507
---
 Build.PL                                     |  2 +-
 Changes                                      |  3 +++
 META.json                                    |  2 +-
 META.yml                                     |  2 +-
 README                                       | 14 ++++++++++++-
 lib/Catmandu/Store/ElasticSearch.pm          | 24 ++++++++++++++++++++--
 lib/Catmandu/Store/ElasticSearch/Bag.pm      | 30 ++++++++++++++++++----------
 lib/Catmandu/Store/ElasticSearch/CQL.pm      |  2 +-
 lib/Catmandu/Store/ElasticSearch/Searcher.pm | 14 +++++++++----
 9 files changed, 71 insertions(+), 22 deletions(-)

diff --git a/Build.PL b/Build.PL
index 74ba603..6ac5240 100644
--- a/Build.PL
+++ b/Build.PL
@@ -18,7 +18,7 @@ my %module_build_args = (
     "Nicolas Steenlant, C<< <nicolas.steenlant at ugent.be> >>"
   ],
   "dist_name" => "Catmandu-Store-Elasticsearch",
-  "dist_version" => "0.0506",
+  "dist_version" => "0.0507",
   "license" => "perl",
   "module_name" => "Catmandu::Store::Elasticsearch",
   "recursive_test_files" => 1,
diff --git a/Changes b/Changes
index 2ed3c56..37a6d50 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Catmandu-Store-ElasticSearch
 
+0.0507  2017-03-10 14:06:16 CET
+  - Elasticsearch 5.0 iteration compatibility
+
 0.0506  2017-02-23 09:53:51 CET
   - more pod
 
diff --git a/META.json b/META.json
index 149fbf5..d985340 100644
--- a/META.json
+++ b/META.json
@@ -69,7 +69,7 @@
          "web" : "https://github.com/LibreCat/Catmandu-Store-Elasticsearch";
       }
    },
-   "version" : "0.0506",
+   "version" : "0.0507",
    "x_contributors" : [
       "Dave Sherohman <dave.sheroh...@ub.lu.se>",
       "Nicolas Steenlant <nicolas.steenl...@gmail.com>",
diff --git a/META.yml b/META.yml
index 0385db1..fde5dbd 100644
--- a/META.yml
+++ b/META.yml
@@ -34,7 +34,7 @@ resources:
   bugtracker: https://github.com/LibreCat/Catmandu-Store-Elasticsearch/issues
   homepage: https://github.com/LibreCat/Catmandu-Store-Elasticsearch
   repository: https://github.com/LibreCat/Catmandu-Store-Elasticsearch.git
-version: '0.0506'
+version: '0.0507'
 x_contributors:
   - 'Dave Sherohman <dave.sheroh...@ub.lu.se>'
   - 'Nicolas Steenlant <nicolas.steenl...@gmail.com>'
diff --git a/README b/README
index e45251f..8f44cb9 100644
--- a/README
+++ b/README
@@ -99,7 +99,7 @@ INDEX MAP
                     _id => {
                         type           => 'string',
                         include_in_all => 'true',
-                        index          => not_analyzed
+                        index          => 'not_analyzed'
                     } ,
                     title => {
                         type           => 'string'
@@ -236,6 +236,18 @@ COMPATIBILITY
 
     This store expects version 1.0 or higher of the Elasticsearch server.
 
+    To talk to older versions of Elasticsearch the approriate client should
+    be installed.
+
+        # Elasticsearch 2.x
+        cpanm Search::Elasticsearch::Client::2_0::Direct
+        # Elasticsearch 1.x
+        cpanm Search::Elasticsearch::Client::1_0::Direct
+
+    And the client version should be specified in the options:
+
+        Catmandu::Store::ElasticSearch->new(index_name => 'myindex', client => 
'1_0::Direct')
+
     Note that Elasticsearch >= 2.0 doesn't allow keys that start with an
     underscore such as _id. You can use the key_prefix option at store
     level or id_prefix at bag level to handle this.
diff --git a/lib/Catmandu/Store/ElasticSearch.pm 
b/lib/Catmandu/Store/ElasticSearch.pm
index d734aea..7eb8016 100644
--- a/lib/Catmandu/Store/ElasticSearch.pm
+++ b/lib/Catmandu/Store/ElasticSearch.pm
@@ -2,10 +2,11 @@ package Catmandu::Store::ElasticSearch;
 
 use Catmandu::Sane;
 
-our $VERSION = '0.0506';
+our $VERSION = '0.0507';
 
 use Moo;
 use Search::Elasticsearch;
+use Catmandu::Util qw(is_instance);
 use Catmandu::Store::ElasticSearch::Bag;
 use namespace::clean;
 
@@ -17,6 +18,8 @@ has index_settings => (is => 'ro', lazy => 1, default => sub 
{ +{} });
 has index_mappings => (is => 'ro', lazy => 1, default => sub { +{} });
 has _es_args => (is => 'rw', lazy => 1, default => sub { +{} });
 has es => (is => 'lazy');
+# used internally
+has is_es_1_or_2 => (is => 'lazy');
 
 sub _build_es {
     my ($self) = @_;
@@ -43,6 +46,12 @@ sub drop {
     $self->es->indices->delete(index => $self->index_name);
 }
 
+sub _build_is_es_1_or_2 {
+    my ($self) = @_;
+    is_instance($self->es, 'Search::Elasticsearch::Client::1_0::Direct') ||
+        is_instance($self->es, 'Search::Elasticsearch::Client::2_0::Direct');
+}
+
 1;
 
 __END__
@@ -146,7 +155,7 @@ bag defined in the index. E.g.
                 _id => {
                     type           => 'string',
                     include_in_all => 'true',
-                    index          => not_analyzed
+                    index          => 'not_analyzed'
                 } ,
                 title => {
                     type           => 'string'
@@ -281,6 +290,17 @@ name of the store, C<search> in this case:
 
 This store expects version 1.0 or higher of the Elasticsearch server.
 
+To talk to older versions of Elasticsearch the approriate client should be 
installed.
+
+    # Elasticsearch 2.x
+    cpanm Search::Elasticsearch::Client::2_0::Direct
+    # Elasticsearch 1.x
+    cpanm Search::Elasticsearch::Client::1_0::Direct
+
+And the client version should be specified in the options:
+
+    Catmandu::Store::ElasticSearch->new(index_name => 'myindex', client => 
'1_0::Direct')
+
 Note that Elasticsearch >= 2.0 doesn't allow keys that start with an 
underscore such as
 C<_id>. You can use the C<key_prefix> option at store level or C<id_prefix> at
 bag level to handle this.
diff --git a/lib/Catmandu/Store/ElasticSearch/Bag.pm 
b/lib/Catmandu/Store/ElasticSearch/Bag.pm
index 12ebab0..14318a8 100644
--- a/lib/Catmandu/Store/ElasticSearch/Bag.pm
+++ b/lib/Catmandu/Store/ElasticSearch/Bag.pm
@@ -2,7 +2,7 @@ package Catmandu::Store::ElasticSearch::Bag;
 
 use Catmandu::Sane;
 
-our $VERSION = '0.0506';
+our $VERSION = '0.0507';
 
 use Moo;
 use Catmandu::Hits;
@@ -40,16 +40,24 @@ sub _build_bulk {
 sub generator {
     my ($self) = @_;
     sub {
-        state $scroll = $self->store->es->scroll_helper(
-            index       => $self->store->index_name,
-            type        => $self->name,
-            search_type => 'scan',
-            size        => $self->buffer_size, # TODO divide by number of 
shards
-            body        => {
-                query => {match_all => {}},
-            },
-        );
-        my $data = $scroll->next // return;
+        state $scroll = do {
+            my %args = (
+                index       => $self->store->index_name,
+                type        => $self->name,
+                size        => $self->buffer_size, # TODO divide by number of 
shards
+                body        => {
+                    query => {match_all => {}},
+                },
+            );
+            if ($self->store->is_es_1_or_2) {
+                $args{search_type} = 'scan';
+            }
+            $self->store->es->scroll_helper(%args);
+        };
+        my $data = $scroll->next // do {
+            $scroll->finish;
+            return;
+        };
         $data->{_source};
     };
 }
diff --git a/lib/Catmandu/Store/ElasticSearch/CQL.pm 
b/lib/Catmandu/Store/ElasticSearch/CQL.pm
index de21d5b..60ef5a9 100644
--- a/lib/Catmandu/Store/ElasticSearch/CQL.pm
+++ b/lib/Catmandu/Store/ElasticSearch/CQL.pm
@@ -2,7 +2,7 @@ package Catmandu::Store::ElasticSearch::CQL;
 
 use Catmandu::Sane;
 
-our $VERSION = '0.0506';
+our $VERSION = '0.0507';
 
 use Catmandu::Util qw(require_package trim);
 use CQL::Parser;
diff --git a/lib/Catmandu/Store/ElasticSearch/Searcher.pm 
b/lib/Catmandu/Store/ElasticSearch/Searcher.pm
index 9fb9dbe..5333cf7 100644
--- a/lib/Catmandu/Store/ElasticSearch/Searcher.pm
+++ b/lib/Catmandu/Store/ElasticSearch/Searcher.pm
@@ -2,7 +2,7 @@ package Catmandu::Store::ElasticSearch::Searcher;
 
 use Catmandu::Sane;
 
-our $VERSION = '0.0506';
+our $VERSION = '0.0507';
 
 use Moo;
 use namespace::clean;
@@ -28,17 +28,23 @@ sub generator {
         state $scroll = do {
             my $body = {query => $self->query};
             $body->{sort} = $self->sort if $self->sort;
-            $store->es->scroll_helper(
+            my %args = (
                 index       => $store->index_name,
                 type        => $self->bag->name,
-                search_type => $self->sort ? 'query_then_fetch' : 'scan',
                 from        => $self->start,
                 size        => $self->bag->buffer_size, # TODO divide by 
number of shards
                 body        => $body,
             );
+            if (!$self->sort && $store->is_es_1_or_2) {
+                $args{search_type} = 'scan';
+            }
+            $store->es->scroll_helper(%args);
         };
 
-        my $data = $scroll->next // return;
+        my $data = $scroll->next // do {
+            $scroll->finish;
+            return;
+        };
         if ($total) {
             $total--;
         }

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libcatmandu-store-elasticsearch-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to