社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Elasticsearch

如果我们有多个嵌套查询,elasticsearch的性能是否会有所不同?

Deepak • 5 年前 • 781 次点击  

一般来说,如果我们需要在一个嵌套类型中进行一个或多个条件,那么,我们就要进行如下查询:

问题1:

{
"query": {
    "bool": {
      "must": [{
        "nested": {
          "query": {
            "bool": {
              "must": [{
                "bool": {
                  "should": [{
                    "match": {
                      "descTags.device": {
                        "query": "abc"
                      }
                    }
                  }, {
                    "match": {
                      "descTags.device": {
                        "query": "xyz"
                      }
                    }
                  }]
                }
              }]
            }
          },
          "path": "descTags"
        }
      }]
    }
  }
}

上面的查询有一个嵌套,并且在此嵌套类型中有或条件。

在下面用两个嵌套blob表示同一查询:

问题2:

{
"query": {
    "bool": {
      "must": [{
        "bool": {
          "should": [{
            "bool": {
              "must": [{
                "nested": {
                  "query": {
                    "bool": {
                      "must": [{
                        "match": {
                          "descTags.Modality": {
                            "query": "abc"
                          }
                        }
                      }]
                    }
                  },
                  "path": "descTags",
                }
              }]
            }
          }, {
            "bool": {
              "must": [{
                "nested": {
                  "query": {
                    "bool": {
                      "must": [{
                        "match": {
                          "descTags.Modality": {
                            "query": "xyz"
                          }
                        }
                      }]
                    }
                  },
                  "path": "descTags"
                }
              }]
            }
          }]
        }
      }]
    }
  }
}

QueRe1和QueRe2在性能上是否有差异,仅仅因为我们有多次嵌套BLB?

编辑1: 根据下面的评论(@卡马尔),我在这里简化了我的问题。

如果布尔操作在“属于同一嵌套类型的属性、只声明一次嵌套类型”的VS“属于同一嵌套类型的属性、声明嵌套类型两次、每次属性一次”之间执行,则性能是否会有所不同。

如下所示:

一。

nested : 
     or : 
         attribute1
         attribute2

2.

or :
     nested : 
        attribute1
     nested :
        attribute2
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/46336
 
781 次点击