elasticsearch-py,Python 2.7,Ubuntu,elasticsearch Py" /> elasticsearch-py,Python 2.7,Ubuntu,elasticsearch Py" />

Python 2.7 带反斜杠的Python查询ElasticSearch路径

Python 2.7 带反斜杠的Python查询ElasticSearch路径,python-2.7,ubuntu,elasticsearch-py,Python 2.7,Ubuntu,elasticsearch Py,我正在使用Python的弹性搜索扩展,试图查询特定路径 以下是我的包装查询: { "size": 1000, "query": { "filtered": { "filter": { "bool": { "must": [ { "term": { "Path": "c:\\myfolder\\myfile.txt" } }

我正在使用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行,内包装 返回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行 状态、标题、数据=连接。执行_请求(方法、url、参数、正文、忽略=忽略、超时=超时)文件 “/usr/local/lib/python2.7/dist packages/elasticsearch/connection/http_urllib3.py”, 执行请求中的第106行 self._raise_error(response.status,raw_data)文件“/usr/local/lib/python2.7/dist packages/elasticsearch/connection/base.py”, 第105行,输入上升错误 引发HTTP_异常。获取(状态代码,传输错误)(状态代码,错误消息,附加信息) elasticsearch.exceptions.RequestError

此问题仅在存在反斜杠时发生

注意:我正在Ubuntu上工作


提前感谢。

尝试将“路径”更改为
c:\\\\myfolder\\\\myfile.txt
谢谢!由于某种原因,我没有想到:)