0
offers
の配列をid
フィールドでフィルタリングし、検索したIDで結果オブジェクトに戻す方法は?idでフィルタリングし、id、Elasticsearchの項目を返す1.7
現在の検索正しく申し出配列内のIDによってデータを見つけるが、それはまた、すべてのオブジェクトを返します。
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"
}
}
},
この答えは役立つかもしれない:http://stackoverflow.com/questions/32773542/fetch単列フィルタリングされた入れ子オブジェクトfrom index-in-elasticsearch/32774267#32774267 – Val
可能な複製http://stackoverflow.com/q/32773542/5936696 – avr