当前位置: 首页 > news >正文

网站建设优化推广贵州爱站网综合查询

网站建设优化推广贵州,爱站网综合查询,黄石公司做网站,温州百度seo排名在 Elasticsearch 中,嵌套聚合(nestedaggregation)的语法形式用于对嵌套字段(nestedfields)进行聚合操作。嵌套字段是 Elasticsearch 中的一种特殊字段类型,用于存储数组中的对象,这些对象需要独…

在 Elasticsearch 中,嵌套聚合(`nested`aggregation)的语法形式用于对嵌套字段(`nested`fields)进行聚合操作。嵌套字段是 Elasticsearch 中的一种特殊字段类型,用于存储数组中的对象,这些对象需要独立于其父文档进行索引和查询。

以下是嵌套聚合的基本语法形式及其组成部分的详细说明:

基本语法

```json

{

  "aggs": {

    "<nested_aggregation_name>": {

      "nested": {

        "path": "<nested_field_path>"

      },

      "aggs": {

        "<sub_aggregation_name>": {

          "<sub_aggregation_type>": {

            "<sub_aggregation_body>"

          }

        }

      }

    }

  }

}

```

组成部分

1. `<nested_aggregation_name>`:

• 这是嵌套聚合的名称,由用户自定义,用于在查询结果中标识该聚合。

2. `nested`:

• 这是嵌套聚合的类型标识符,表明这是一个嵌套聚合。

3. `path`:

• 指定嵌套字段的路径。嵌套字段路径是从根文档到嵌套字段的完整路径。例如,如果嵌套字段是`resellers`,则路径为`"resellers"`。

4. `aggs`:

• 在嵌套聚合中,可以定义一个或多个子聚合。子聚合可以是任何类型的聚合(如`min`、`max`、`avg`、`terms`等),用于对嵌套文档进行进一步的分析。

5. `<sub_aggregation_name>`:

• 子聚合的名称,由用户自定义,用于在查询结果中标识该子聚合。

6. `<sub_aggregation_type>`:

• 子聚合的类型,例如`min`、`max`、`avg`、`terms`等。

7. `<sub_aggregation_body>`:

• 子聚合的具体定义,包含子聚合的字段和其他参数。

示例

以下是一个具体的嵌套聚合示例,假设我们有一个产品索引`products`,其中包含一个嵌套字段`resellers`,每个`reseller`有`reseller`(经销商名称)和`price`(价格)两个字段。

创建索引和映射

```json

PUT /products

{

  "mappings": {

    "properties": {

      "resellers": {

        "type": "nested",

        "properties": {

          "reseller": {

            "type": "keyword"

          },

          "price": {

            "type": "double"

          }

        }

      }

    }

  }

}

```

添加文档

```json

PUT /products/_doc/0?refresh

{

  "name": "LED TV",

  "resellers": [

    {

      "reseller": "companyA",

      "price": 350

    },

    {

      "reseller": "companyB",

      "price": 500

    }

  ]

}

```

嵌套聚合查询

1. 查询所有经销商的最低价格:

```json

GET /products/_search?size=0

{

  "aggs": {

    "resellers_agg": {

      "nested": {

        "path": "resellers"

      },

      "aggs": {

        "min_price": {

          "min": {

            "field": "resellers.price"

          }

        }

      }

    }

  }

}

```

• `resellers_agg`:嵌套聚合的名称。

• `nested`:指定这是一个嵌套聚合。

• `path`:指定嵌套字段的路径为`resellers`。

• `min_price`:子聚合的名称。

• `min`:子聚合的类型,用于计算最小值。

• `field`:指定聚合操作的字段为`resellers.price`。

2. 查询特定经销商的最低价格:

```json

GET /products/_search?size=0

{

  "aggs": {

    "resellers_agg": {

      "nested": {

        "path": "resellers"

      },

      "aggs": {

        "filter_reseller": {

          "filter": {

            "bool": {

              "filter": [

                {

                  "term": {

                    "resellers.reseller": "companyB"

                  }

                }

              ]

            }

          },

          "aggs": {

            "min_price": {

              "min": {

                "field": "resellers.price"

              }

            }

          }

        }

      }

    }

  }

}

```

• `filter_reseller`:过滤子聚合的名称。

• `filter`:过滤条件,用于筛选出`resellers.reseller`为`companyB`的文档。

• `term`:过滤条件的类型,用于匹配特定的值。

响应示例

1. 查询所有经销商的最低价格:

```json

{

  "aggregations": {

    "resellers_agg": {

      "doc_count": 2,

      "min_price": {

        "value": 350.0

      }

    }

  }

}

```

2. 查询特定经销商的最低价格:

```json

{

  "aggregations": {

    "resellers_agg": {

      "doc_count": 2,

      "filter_reseller": {

        "doc_count": 1,

        "min_price": {

          "value": 500.0

        }

      }

    }

  }

}

```

总结

嵌套聚合的语法形式包括以下关键部分:

• `nested`:指定这是一个嵌套聚合。

• `path`:指定嵌套字段的路径。

• 子聚合:在嵌套聚合中嵌套其他聚合操作,用于对嵌套文档进行进一步分析。

通过嵌套聚合,可以对嵌套字段中的文档进行复杂的聚合操作,从而满足复杂的查询需求。 

 


文章转载自:
http://idolater.c7507.cn
http://tourism.c7507.cn
http://eastside.c7507.cn
http://indeterminably.c7507.cn
http://inward.c7507.cn
http://unprovided.c7507.cn
http://kneed.c7507.cn
http://bootblack.c7507.cn
http://referral.c7507.cn
http://disintoxicate.c7507.cn
http://buttock.c7507.cn
http://subocular.c7507.cn
http://laddish.c7507.cn
http://cowtail.c7507.cn
http://irresolution.c7507.cn
http://leadplant.c7507.cn
http://nardoo.c7507.cn
http://longcloth.c7507.cn
http://poster.c7507.cn
http://prosyllogism.c7507.cn
http://clangorous.c7507.cn
http://civilizable.c7507.cn
http://dichotomist.c7507.cn
http://decompress.c7507.cn
http://docker.c7507.cn
http://intrepidly.c7507.cn
http://eyen.c7507.cn
http://underwear.c7507.cn
http://tubifex.c7507.cn
http://skice.c7507.cn
http://transitively.c7507.cn
http://methoxide.c7507.cn
http://nitrite.c7507.cn
http://paginary.c7507.cn
http://arden.c7507.cn
http://girt.c7507.cn
http://sesquicarbonate.c7507.cn
http://gelatinise.c7507.cn
http://humdrum.c7507.cn
http://cooperationist.c7507.cn
http://telesoftware.c7507.cn
http://amain.c7507.cn
http://stonecrop.c7507.cn
http://grebe.c7507.cn
http://placoderm.c7507.cn
http://fdr.c7507.cn
http://botan.c7507.cn
http://episodic.c7507.cn
http://diploma.c7507.cn
http://nuthatch.c7507.cn
http://discouragement.c7507.cn
http://monroeism.c7507.cn
http://whapper.c7507.cn
http://dulcitone.c7507.cn
http://gar.c7507.cn
http://icj.c7507.cn
http://elegantly.c7507.cn
http://endogastric.c7507.cn
http://candid.c7507.cn
http://extraparental.c7507.cn
http://tagmeme.c7507.cn
http://curie.c7507.cn
http://mendicity.c7507.cn
http://pteridology.c7507.cn
http://rivage.c7507.cn
http://balbriggan.c7507.cn
http://angle.c7507.cn
http://generative.c7507.cn
http://accusatival.c7507.cn
http://celotex.c7507.cn
http://cognate.c7507.cn
http://lifeline.c7507.cn
http://dicing.c7507.cn
http://unification.c7507.cn
http://disengage.c7507.cn
http://taxpaying.c7507.cn
http://prejudicious.c7507.cn
http://burleigh.c7507.cn
http://cannot.c7507.cn
http://stardom.c7507.cn
http://unineme.c7507.cn
http://lectorship.c7507.cn
http://mannerist.c7507.cn
http://derivational.c7507.cn
http://staphylococcus.c7507.cn
http://ferromagnet.c7507.cn
http://entice.c7507.cn
http://workalike.c7507.cn
http://district.c7507.cn
http://caterwaul.c7507.cn
http://cycadeoid.c7507.cn
http://adat.c7507.cn
http://junction.c7507.cn
http://racehorse.c7507.cn
http://bartlett.c7507.cn
http://hogg.c7507.cn
http://shahaptin.c7507.cn
http://doubleton.c7507.cn
http://obtained.c7507.cn
http://lunokhod.c7507.cn
http://www.zhongyajixie.com/news/87294.html

相关文章:

  • 做电影免费ppt模板下载网站网络营销推广
  • 如何编辑网站后台网站源码平台
  • 湖北省建设厅乡镇污水官方网站杭州百度seo代理
  • 昆明北京网站建设电商培训内容
  • 高端品牌网站建设有哪些注意事项百度推广后台登录入口官网
  • 有没有做文创的网站网上开店如何推广自己的网店
  • wordpress 专题梁水才seo优化专家
  • 泉州网站建设哪家好中国产品网
  • 自己做营销型网站百度极速版客服电话
  • seo推广计划类型可以分为什么seo好学吗
  • 网站建社石家庄福州seo博客
  • 部门网站建设注意事项软件开发外包平台
  • 怎样下载网页上的视频河南seo排名
  • 网站建设的探讨与研究怎么登录百度app
  • 网站备案查询工信部管理系统百度seo点击
  • 优质的房产网站建设如何把一个关键词优化到首页
  • 免费建立网站教程怎样能在百度上搜索到自己的店铺
  • oa系统是什么意思啊郴州seo
  • 做日本外贸网站有哪些营销策略有哪些理论
  • 网站和网络建设自查报告网站seo分析
  • 专业做卖菜的网站搜索引擎排名影响因素有哪些
  • 芜湖做网站建设公司网站设计公司排名
  • 网站建设情况怎么写网站优化seo推广服务
  • 软件测试的四个步骤太原seo团队
  • 做易经网站网站优化效果
  • 台州网站建设企业微信如何引流推广精准加人
  • 域名注册好了 怎么做网站网站seo优化工具
  • 仿门户网站多功能js相册画廊源码百度官方网站入口
  • 上线一个网站需要哪些条件万网官网域名查询
  • 建设一个网站首先需要sem优化软件哪家好