我是elasticsearch的新手,我想进行过滤搜索: 我的映射的一部分是这样的:
"_index" : "project",
"_type" : "flat_order",
"_id" : "795",
"_score" : 2.1372108,
"fields" : {
"status" : "canceled",
"created_at" : "2012-01-04 12:48:48",
"updated_at" : "2012-02-21 07:19:35"
}
}, {
"_index" : "project",
"_type" : "flat_order",
"_id" : "803",
"_score" : 2.1372108,
"fields" : {
"status" : "canceled",
"created_at" : "2012-01-04 12:50:54",
"updated_at" : "2012-02-21 07:19:35"
}
我希望所有索引的created_at都在gte:"2012-01-01 00:00:00",lte:"2012-02-01 00:00:00"
范围内,并且status :"cancelled" or "confirmed"
。
提前致谢
答案 0 :(得分:1)
得到了解决方案:
$ curl -X GET http://localhost:9200/project/flat_order/_search?pretty=true -d '{
"fields": [
"created_at",
"status"
],
"query": {
"filtered": {
"query": {
"range": {
"created_at": {
"gte": "2012-01-01 00:00:00",
"lte": "2012-02-01 00:00:00"
}
}
},
"filter": {
"or": [
{
"term": {
"status": "canceled"
}
},
{
"term": {
"status": "confirmed"
}
}
]
}
}
}
}