【发布时间】:2019-02-04 00:37:57
【问题描述】:
您好,我正在尝试获取一个查询以根据对象数组中的值进行过滤,结构是这样的
{
"_index": "test",
"_type": "home",
"_id": "1247816",
"_score": 1,
"_source": {
"TranCust": {
"CustId": 1247816,
"sourceNodeName": "SRC"
},
"TranList": [
{
"TranId": 2431015,
"batchNr": "211"
},
{
"TranId": 2431016,
"batchNr": "213"
}
]
}
}
例如,我想查找 TranId 为 2431015 的所有文档,我的查询如下所示
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "TranList",
"query": {
"bool": {
"must": [
{
"match": {
"TranId": "2431015"
}
}
]
}
}
}
}
]
}
}
}
它似乎没有返回任何结果,有没有更好的方法来尝试编写这个查询?
编辑, 这是放入的映射
{
"mappings": {
"home": {
"properties": {
"TranCust": {
"type": "object"
}
},
"TranList": {
"type": "nested"
}
}
}
}
}
【问题讨论】:
-
您确定您的对象存储为
nested type,而不是object? -
我已经添加了我在问题中输入的映射
标签: elasticsearch