高峰只对攀登它而不是仰望它的人来说才有真正意义。

nested 数组嵌套对象查询

Elasticsearch | 作者 tgx | 发布于2017年05月11日 | 阅读数:6158

在索引中,有nested类型的字段params有3条数据如下:
 
[
    {
        "type":1
    }
]

[
    {
        "type":2
    }
]

[
    {
        "type":1
    },
    {
        "type":2
    }
]
 
我如何拿出 同时含有 type值为 1 和2的数据
已邀请:

caster

赞同来自:

按照目前存储的形式,试试should 有没有效。没测过
minimum_should_match": 2,
"should": [
{
"nested": {
"path": "yourpath",
"query": {
"bool": {
"filter": [{
"term": {
"yourpath.type": 1
}
}
]
}
}
}
}, {
"nested": {
"path": "props",
"query": {
"bool": {
"filter": [{
"term": {
"yourpath.type": 2
}
}
]
}
}
}
}
]


另外一个建议:为什么不存成数组的形式?这样不是好搜多了
{
type:[1,2]
}

要回复问题请先登录注册