【发布时间】:2017-04-14 19:12:15
【问题描述】:
如何通过id 字段过滤offers 数组并返回带有搜索ID 的结果对象?
当前搜索通过 id 在 offer 数组中正确查找数据,但它也返回它的所有对象:
GET activities/activity/_search
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"offers.id": "12"
}
}
]
}
}
}
}
}
当前结果,我想过滤报价并仅使用"id": 12 获得:
"hits": [
{
"_index": "activities",
"_type": "activity",
"_id": "AVtr4-UV81wMr8KFD246",
"_score": null,
"_source": {
"offers": [
{
"title": "merge",
"id": 11
},
{
"title": "order test",
"id": 12
}
],
"event": "candidate_remove",
"created_at": "2017-04-14T09:55:49.115174Z"
}
}
]
活动类型中的优惠映射:
"offers": {
"type": "nested",
"include_in_parent": true,
"properties": {
"id": {
"type": "long"
},
"title": {
"type": "string",
"index": "not_analyzed"
}
}
},
【问题讨论】:
标签: elasticsearch