1
记录Elasticsearch存储:和查询elasticsearch蟒蛇
"hits" : [ {
"_index" : "test",
"_type" : "test_doc",
"_id" : "AVUHBSESPB1nLi5k2Dxp",
"_score" : 1.0,
"_source":{"valid": true,"action_taken": false}
}, {
"_index" : "test",
"_type" : "test_doc",
"_id" : "AVUHBI1IPB1nLi5k2Dxo",
"_score" : 1.0,
"_source":{"valid": true,"action_taken": false}
}, {
"_index" : "test",
"_type" : "test_doc",
"_id" : "AVUHWFipPB1nLi5k2Dxu",
"_score" : 1.0,
"_source":{"valid": false,"action_taken": false}
} ]
我们需要找到那些记录有效的真实,ACTION_TAKEN使用elasticsearch Python包是python脚本错误。
我们正在尝试使用
resp = ES.search(index='test', doc_type='test_doc', q='action_taken:0 valid:1)
但是执行上做同样的,它返回的所有记录。 是否有任何可能的方式使用搜索来做同样的事情?
PS:我试图编写一个API调用,它根据请求中提供的json数据提供的搜索条件来搜索记录。
所以我们应该需要通过上面提出的整个json作为查询参数在es搜索函数中调用resp = ES.search(index ='test',doc_type ='test_doc',query =') –
user3351750
它的工作原理使用'resp = ES.search(index ='test',doc_type ='test_doc',body =)' –
user3351750