1
使用curl Python語法,以下請求的工作原理:Elasticsearch - 從工作捲曲例如
curl -XGET 'localhost:9200/dumperino/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"bool": {
"should": [
{ "match": { "id_1": "4000000029898186" }},
{ "match": { "id_2": "4000000029898188" }}
]
}
}
}
'
我現在試圖通過Python使用elasticsearch。
from elasticsearch import helpers
es = elasticsearch.Elasticsearch()
qu={
"query": {
"bool": {
"should": [
{ "match": { "id_1": "4000000029898186" }},
{ "match": { "id_2": "4000000029898188" }}
]
}
}
}
result = es.search(index= "dumperino",q=qu)
錯誤: elasticsearch.exceptions.RequestError: TransportError(400, u'search_phase_execution_exception', u"Failed to parse query [{'query': {'bool': {'should': [{'match': {'id_1': '4000000029898186'}}, {'match': {'id_2': '4000000029898188'}}]}}}]")
我之前已經成功地使用過這種格式,儘管有一個簡單的查詢字符串。
我需要在彈性搜索的JSON查詢中更改以在Python中正確解析此問題?