在弹性搜索中删除索引时出错

Error while deleting a index in Elastic search

我正在使用弹性搜索 Python API。我创建了一个名为 "sample" 的索引。但是,在尝试删除时遇到异常。以下是我的做法。

弹性搜索实例,

es = Elasticsearch("abc.def.ghi.jkl:9300")

检查索引是否存在

es.indices.exists(index="sample")
True

正在尝试删除索引,

es.indices.delete(index="sample") 

错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/adaggula/anaconda/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/Users/adaggula/anaconda/lib/python2.7/site-packages/elasticsearch/client/indices.py", line 200, in delete
    params=params)
  File "/Users/adaggula/anaconda/lib/python2.7/site-packages/elasticsearch/transport.py", line 353, in perform_request
    data = self.deserializer.loads(data, headers.get('content-type'))
  File "/Users/adaggula/anaconda/lib/python2.7/site-packages/elasticsearch/serializer.py", line 76, in loads
    return deserializer.loads(s)
  File "/Users/adaggula/anaconda/lib/python2.7/site-packages/elasticsearch/serializer.py", line 40, in loads
    raise SerializationError(s, e)
elasticsearch.exceptions.SerializationError: (u'This is not a HTTP port', ValueError('No JSON object could be decoded',))

不知道为什么会出现这个错误。

您需要使用专用于 HTTP 通信的端口 9200 而不是专用于 TCP 通信的 9300

es = Elasticsearch("abc.def.ghi.jkl:9200")
                                     ^
                                     |
                                change this