Humbedooh commented on issue #489: Errors with Elasticsearch 5.x
URL: 
https://github.com/apache/incubator-ponymail/issues/489#issuecomment-486481263
 
 
   The first bit can be addressed with this snippet, which I intend to commit 
shortly...
   There will be some other future changes, as I am aware we need to switch 
away from doc_types altogether for newer ESes
   ~~~ diff
   diff --git a/tools/elastic.py b/tools/elastic.py
   index 897cb64..4f7517c 100755
   --- a/tools/elastic.py
   +++ b/tools/elastic.py
   @@ -109,14 +109,24 @@ class Elastic:
            )
    
        def scan(self, doc_type='mbox', scroll='3m', size = 100, **kwargs):
   -        return self.es.search(
   -            index=self.dbname,
   -            doc_type=doc_type,
   -            search_type = 'scan',
   -            size = size,
   -            scroll = scroll,
   -            **kwargs
   -        )
   +        """ Call the scan API, passing on the search type if needed 
(ES<=2.x) """
   +        if self.engineMajor() <= 2:
   +            return self.es.search(
   +                index=self.dbname,
   +                doc_type=doc_type,
   +                search_type = 'scan',
   +                size = size,
   +                scroll = scroll,
   +                **kwargs
   +            )
   +        else:
   +            return self.es.search(
   +                index=self.dbname,
   +                doc_type=doc_type,
   +                size = size,
   +                scroll = scroll,
   +                **kwargs
   +            )
    
        def get(self, **kwargs):
            return self.es.get(index=self.dbname, **kwargs)
   ~~~

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to