I'm working with an elastic API on a url like https://something.xyzw.eg/api/search/advance (not the real url). The API works fine on postman. Also the python code generated by postman works fine and returns results. However when using leasticsearch-dsl package I keep getting:
Failed to establish a new connection: [Errno -2] Name or service not known)
Here is my code similar to the first example on documents:
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search
client = Elasticsearch(host='https://something.xyzw.eg/api/search/advance')
s = Search(using=client)
response = s.execute()
Any idea what I'm doing wrong?
Edit:
Apparently host shouldn't contain a url, but a hostname. However, I don't have any control on where the API is. Is there a workaround to get elasticsearch to work with url?
CodePudding user response:
Can you try to add port=443 as in one of the examples from the doc you mentioned https://elasticsearch-py.readthedocs.io/en/v7.16.3/#tls-ssl-and-authentication ?
CodePudding user response:
For reference: it turned out that the API I was using wasn't in fact the standard ElasticSearch, but would proxy my request to the ElasticSearch. So sending requests by postman and requests package would work (as the requsets were sent to Elastic), but elasticsearch-py couldn't connect to it (since the route I was trying to connect to wasn't actually Elastic itself).
