Elasticsearch对父子搜索的查询性能很差

问题描述

我有一个索引,其中包含400.000个儿童文档和4000个父母。这意味着我每个父母大约有100个孩子的证件。

每个父母都是这样的:

{ id: 1,field: ["A","B"],join: {name:"parent"} }
{ id: 2,field: ["C",join: {name:"parent"} }
{ id: 3,field: ["D","A"],join: {name:"parent"} }

孩子就像:

{ id: "A",title: "Title A",join: {name:"child",parent: 1}}
{ id: "B",title: "Title B",parent: 3}}
{ id: "C",title: "Title C",parent: 2}}
{ id: "D",title: "Title D",parent: 1}}

执行hasParent查询时,查询中包含的参数越多,速度越快。

在下面的查询中,术语参数[“ A”,“ B”,“ C”]的运行速度比[“ A”]快。

{
  "query": {
    "bool": {
      "must": [
        {
          "match_all": {}
        }
      ],"filter": [
        {
          "bool": {
            "minimum_should_match": 1,"should": [
              {
                "has_parent": {
                  "parent_type": "other","query": {
                    "bool": {
                      "should": [
                        {
                          "terms": {
                            "field": ["A","B","C"]
                          }
                        }
                      ]
                    }
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

有人知道为什么会这样吗?

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)