question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support multiple versions including versions 1.x

See original GitHub issue

Hello, Is there a way to support all versions including versions 1.x? Until now i have support for 2.x.y, 5.x.y and 6.x.y ( I followed the information in the link elasticsearch -compatibility

My install_requires in setup.py:

install_requires=[
        "elasticsearch2",
        "elasticsearch5",
        "elasticsearch>=6.0.0,<7.0.0",
        "certifi==2017.4.17"
    ],

The problem is that i need to support also versions 1.x.y. I tried to collect data for elasticsearch version 1.x.y and I got an error:

  File "/Users/Offir/ve/elasticsearch/lib/python2.7/site-packages/es/es.py", line 37, in wrapped
    print str(e)
  File "/Users/Offir/ve/elasticsearch/lib/python2.7/site-packages/elasticsearch/exceptions.py", line 58, in __str__
    cause = ', %r' % self.info['error']['root_cause'][0]['reason']
TypeError: string indices must be integers

I added “elasticsearch>=1.0.0,<2.0.0” to the install_requires and I was able to get my data without errors (for elasticsearch version 1.x.y) but then I didn’t had support for elasticsearch version 6.x.y and i got different error:

File "/Users/Offir/ve/elasticsearch/lib/python2.7/site-packages/es/es.py", line 44, in wrapped
    raise Exception(msg)
Exception: Content-Type header is missing

I tried to do add something like elasticsearch>=1.0.0,<7.0.0 and elasticsearch1 but it didn’t work and I got the same error for elasticsearch version 6.x.y.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
fxdgearcommented, Jan 14, 2019

When I added elasticsearch1 to the install_requires I was able to fetch data from elasticsearch 1 cluster version but I got an error Content-Type header is missing when trying to fetch data from elasticsearch 6 cluster version.

this is to be expected because an elasticsearch cluster running es6 has a strict requirement on the Content-Type header. You can see here that the support for explicitly adding a Content-Type was added https://github.com/elastic/elasticsearch-py/commit/d862c8a799e485649da3beaef7037860d01ac3e5

Prior to this commit, content-type was not sent along in the request to Elasticsearch, which means if you’re trying to use a connection class from before this commit (ie in elasticsearch1) it will not have the header information built into the connection class.

There are other issues as well with trying to use a connection class from a prior version fo Elasticsearch-py on a current version of Elasticsearch. Which is why you need to import them all. Then you need to have knowledge of what version a particular cluster is running before you create the connection object.

0reactions
Offircommented, Jan 14, 2019

@fxdgear Thank you for your help 😃 I installed elasticsearch2, elasticsearch5 and elasticsearch>=6.0.0,<7.0.0 then using import elasticsearch (according to https://elasticsearch-py.readthedocs.io/en/master/#compatibility) I was able to support all versions of elasticsearch (expect of elasticsearch1). That’s why I taught that installing elasticsearch1 will work as well so I could avoid doing:

from elasticsearch1 import elasticsearch as elasticsearch1
from elasticsearch2 import elasticsearch as elasticsearch2
from elasticsearch5 import elasticsearch as elasticsearch5
from elasticsearch import elasticsearch as elasticsearch6

When I added elasticsearch1 to the install_requires I was able to fetch data from elasticsearch 1 cluster version but I got an error Content-Type header is missing when trying to fetch data from elasticsearch 6 cluster version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support multiple versions of ASP.NET Core Web API
In this post, let's find how to support multiple version ASP.NET Core Web API. ... Open Project.json and include following nuget package.
Read more >
Make the client better support multiple different versions #127
The scenario that I'm worried about with the multiple branch situation is how the client can handle upgrading elasticsearch server versions.
Read more >
DPI Version 1.x base code considerations - IBM
For example, the z/OS SNMP agent provides support for multiple versions of DPI, including Version 1.0, Version 1.1, and Version 2.0. Parent topic:...
Read more >
How versioning works in lists and libraries - Microsoft Support
Learn how to view the version history of documents and items in your library, ... version better, you can replace the current version...
Read more >
Semantic Versioning 2.0.0 | Semantic Versioning
In systems with many dependencies, releasing new package versions can quickly become a ... Dependency hell is where you are when version lock...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found