【发布时间】:2016-03-03 09:26:27
【问题描述】:
我正在使用 Python 的弹性搜索扩展,尝试查询特定路径。
这是我的包装查询:
{
"size": 1000,
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"Path": "c:\\myfolder\\myfile.txt"
}
}
]
}
}
}
}
}
在 kopf 插件中效果很好。
这是我的 Python 代码:
from elasticsearch import Elasticsearch
es = Elasticsearch(hosts=['my_server'])
index = "my_index"
query = '{"size":1000,"query":{"filtered":{"filter":{"bool":{"must":[{"term":{"Path":"c:\\myfolder\\myfile.txt"}}]}}}}}'
response = es.search(index=index, body=query)
由于某种原因,我收到了这个错误(没有反斜杠就不会发生):
/usr/local/lib/python2.7/dist-packages/elasticsearch/client/utils.py", 第 69 行,在 _wrapped 中 return func(*args, params=params, **kwargs) 文件 "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/init.py", 第 530 行,搜索中 doc_type, '_search'), params=params, body=body) 文件 "/usr/local/lib/python2.7/dist-packages/elasticsearch/transport.py", 第 329 行,在 perform_request 中 状态、标头、数据 = connection.perform_request(方法、url、参数、正文、忽略=忽略、超时=超时)文件 "/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/http_urllib3.py", 第 106 行,在 perform_request 中 self._raise_error(response.status, raw_data) 文件“/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/base.py”, 第 105 行,在 _raise_error 引发 HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info) elasticsearch.exceptions.RequestError
只有在有反斜杠时才会出现这个问题。
注意:我正在开发 Ubuntu。
提前致谢。
【问题讨论】:
标签: python-2.7 ubuntu elasticsearch-py