【发布时间】:2017-11-08 21:35:04
【问题描述】:
我有以下文件
{
"id": 1,
"store": "xyz",
"products": [
{
"object": {
"name": "chair",
"code": "2584"
},
"parts": [
{
"material": "wood"
},
{
"material": "steel"
}
]
}
]
},
{
"id": 2,
"store": "abc",
"products": [
{
"object": {
"name": "chair",
"code": "2584"
},
"parts": [
{
"material": "wood"
},
{
"material": "steel"
}
]
},
{
"object": {
"name": "table",
"code": "2678"
},
"parts": [
{
"material": "wood"
},
{
"material": "steel"
}
]
}
]
}
所以它是这样的:商店列表 -> 产品列表 -> 零件列表
现在我想查询所有在产品列表中有椅子的商店,但我不想在响应中包含所有产品
例如,商店“abc”应该为查询返回:
{
"id": 2,
"store": "abc",
"products": [
{
"object": {
"name": "chair",
"code": "2584"
},
"parts": [
{
"material": "wood"
},
{
"material": "steel"
}
]
}
}
目前我的映射是:
"products.object": {
"type": "object",
"properties": {
"code": {
"type": "text",
"fielddata": true
},
"name": {
"type": "text",
"fielddata": true
}
}
},
"products.parts": {
"store": false,
"type": "long",
"index": false
},
我应该使用什么类型的查询以及应该如何进行映射?
提前谢谢你
编辑:
补充一下我的问题,我的目标是删除所有与 hits 数组中的查询不匹配的产品
所以响应应该包含 id、变量“store”等等。但不是与名称“椅子”不匹配的产品(以呼应我的示例)
【问题讨论】:
标签: elasticsearch elasticsearch-5