怎么又是你

有关has_parent 和has_child的问题

Elasticsearch | 作者 xitng8 | 发布于2019年07月12日 | 阅读数:1263

has_parent里,怎么使用子节点的字段啊,就类似 mysql inner join on 多个字段相等
比如 search table1
{
    "size": 0,
    "query": {
        "bool": {
            "must": [
                {
                    "terms": {
                        "a_id": [
                            1
                        ]
                    }
                },
                {
                    "has_parent": {
                        "query": {
                            "bool": {
                                "must": [
                                    {
                                        "nested": {
                                            "query": {
                                                "bool": {
                                                    "must": [
                                                        {
                                                            "terms": {
                                                                "nested_field.a_id": [
                                                                    1
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                }
                                            },
                                            "path": "nested_field"
                                        }
                                    }
                                ]
                            }
                        },
                        "type": "table2"
                    }
                }
            ]
        }
    }
}
原本table1 和table2 就用id关联成父子关系了,现在还想再用查询的时候,把他们的a_id 关联起来,elastic里不知道怎么实现
已邀请:

要回复问题请先登录注册