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

网站在美国做的服务器咖啡的营销推广软文

网站在美国做的服务器,咖啡的营销推广软文,网站是否能够被恶意镜像,一键发布多个自媒体平台提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 1.聚合(aggregations)基本概念桶(bucket)度量(metrics) 案例 11. 接下来按price字段进行分组:2. 若想对所…

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录

  • 1.聚合(aggregations)
    • 基本概念
      • ==桶(bucket)==
      • ==度量(metrics)==
    • 案例 1
      • 1. 接下来按price字段进行分组:
      • 2. 若想对所有手机价格求平均值。
    • 案例 2
      • 1. 搜索address中包含mill的所有人的年龄分布以及平均年龄
      • 2. 按照年龄聚合,并且请求这些年龄段的这些人的平均薪资
      • 3. 查出所有年龄分布,并且这些年龄段中M的平均薪资和F的平均薪资以及这个年龄段的总体平均薪资
  • 2.映射配置(_mapping)
    • ElasticSearch7-去掉type概念: ![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/13e3511789084d46b0614848a9984c1a.png)
    • 2.1 什么是映射?
        • 映射是定义文档的过程,文档包含哪些字段,这些字段是否保存,是否索引,是否分词等
    • 2.2 查看索引库中所有的属性的_mapping
    • 2.3 创建映射字段
      • 新增映射字段
    • 2.4 更新映射
    • 2.5 数据迁移
    • 2.6 映射案例
        • 报错只因创建映射时"tel"的"index"为false。


1.聚合(aggregations)

  • 聚合允许使用者对 es 文档进行统计分析,类似与关系型数据库中的 group by,当然还有很多其他的聚合,例如取最大值max、平均值avg等等。

基本概念

Elasticsearch中的聚合,包含多种类型,最常用的两种,一个叫 ,一个叫 度量

桶(bucket)

在这里插入图片描述

度量(metrics)

在这里插入图片描述

案例 1

1. 接下来按price字段进行分组:

在 Postman 中,向 ES 服务器发 GET请求 : http://127.0.0.1:9200/shopping/_search,附带JSON体如下:

{"aggs":{//聚合操作"price_group":{//名称,随意起名"terms":{//分组"field":"price"//分组字段}}}
}

返回结果如下:

{"took": 63,"timed_out": false,"_shards": {"total": 1,"successful": 1,"skipped": 0,"failed": 0},"hits": {"total": {"value": 6,"relation": "eq"},"max_score": 1,"hits": [{"_index": "shopping","_type": "_doc","_id": "ANQqsHgBaKNfVnMbhZYU","_score": 1,"_source": {"title": "小米手机","category": "小米","images": "http://www.gulixueyuan.com/xm.jpg","price": 3999}},{"_index": "shopping","_type": "_doc","_id": "A9R5sHgBaKNfVnMb25Ya","_score": 1,"_source": {"title": "小米手机","category": "小米","images": "http://www.gulixueyuan.com/xm.jpg","price": 1999}},{"_index": "shopping","_type": "_doc","_id": "BNR5sHgBaKNfVnMb7pal","_score": 1,"_source": {"title": "小米手机","category": "小米","images": "http://www.gulixueyuan.com/xm.jpg","price": 1999}},{"_index": "shopping","_type": "_doc","_id": "BtR6sHgBaKNfVnMbX5Y5","_score": 1,"_source": {"title": "华为手机","category": "华为","images": "http://www.gulixueyuan.com/xm.jpg","price": 1999}},{"_index": "shopping","_type": "_doc","_id": "B9R6sHgBaKNfVnMbZpZ6","_score": 1,"_source": {"title": "华为手机","category": "华为","images": "http://www.gulixueyuan.com/xm.jpg","price": 1999}},{"_index": "shopping","_type": "_doc","_id": "CdR7sHgBaKNfVnMbsJb9","_score": 1,"_source": {"title": "华为手机","category": "华为","images": "http://www.gulixueyuan.com/xm.jpg","price": 1999}}]},"aggregations": {"price_group": {"doc_count_error_upper_bound": 0,"sum_other_doc_count": 0,"buckets": [{"key": 1999,"doc_count": 5},{"key": 3999,"doc_count": 1}]}}
}

上面返回结果会附带原始数据的。若不想要不附带原始数据的结果, 设置"size":0

在 Postman 中,向 ES 服务器发 GET请求 : http://127.0.0.1:9200/shopping/_search,附带JSON体如下

{"aggs":{"price_group":{"terms":{"field":"price"}}},"size":0
}

返回结果如下:

{"took": 60,"timed_out": false,"_shards": {"total": 1,"successful": 1,"skipped": 0,"failed": 0},"hits": {"total": {"value": 6,"relation": "eq"},"max_score": null,"hits": []},"aggregations": {"price_group": {"doc_count_error_upper_bound": 0,"sum_other_doc_count": 0,"buckets": [{"key": 1999,"doc_count": 5},{"key": 3999,"doc_count": 1}]}}
}

2. 若想对所有手机价格求平均值。

在 Postman 中,向 ES 服务器发 GET请求 : http://127.0.0.1:9200/shopping/_search,附带JSON体如下:

{"aggs":{"price_avg":{//名称,随意起名"avg":{//求平均"field":"price"}}},"size":0
}

返回结果如下:

{"took": 14,"timed_out": false,"_shards": {"total": 1,"successful": 1,"skipped": 0,"failed": 0},"hits": {"total": {"value": 6,"relation": "eq"},"max_score": null,"hits": []},"aggregations": {"price_avg": {"value": 2332.3333333333335}}
}

案例 2

1. 搜索address中包含mill的所有人的年龄分布以及平均年龄

在这里插入图片描述

2. 按照年龄聚合,并且请求这些年龄段的这些人的平均薪资

在这里插入图片描述

3. 查出所有年龄分布,并且这些年龄段中M的平均薪资和F的平均薪资以及这个年龄段的总体平均薪资

在这里插入图片描述

2.映射配置(_mapping)

ElasticSearch7-去掉type概念: 在这里插入图片描述

Elasticsearch 7.x

  • URL中的type参数为可选。比如,索引一个文档不再要求提供文档类型。

Elasticsearch 8.x

  • 不再支持URL中的type参数。

  • 解决:将索引从多类型迁移到单类型,每种类型文档一个独立索引

2.1 什么是映射?

有了索引库,等于有了数据库中的 database。接下来就需要建索引库(index)中的映射了,类似于数据库(database)中的表结构(table)。

  • 创建数据库表需要设置字段名称,类型,长度,约束等;索引库也一样,需要知道这个类型下有哪些字段,每个字段有哪些约束信息,这就叫做映射(mapping)
映射是定义文档的过程,文档包含哪些字段,这些字段是否保存,是否索引,是否分词等

2.2 查看索引库中所有的属性的_mapping

在这里插入图片描述

2.3 创建映射字段

在这里插入图片描述
类型名称:就是前面将的type的概念,类似于数据库中的不同表

字段名:类似于列名,properties下可以指定许多字段。

每个字段可以有很多属性。例如:

  • type:类型,可以是text、long、short、date、integer、object等
  • index:是否索引,默认为true
  • store:是否存储,默认为false
  • analyzer:分词器,这里使用ik分词器:ik_max_word或者ik_smart

在这里插入图片描述

新增映射字段

如果我们创建完成索引的映射关系后,又要添加新的字段的映射,这时怎么办?第一个就是先删除索引,然后调整后再新建索引映射,还有一个方式就在已有的基础上新增。
在这里插入图片描述
在这里插入图片描述

2.4 更新映射

  • 对于存在的映射字段,我们不能更新,更新必须创建新的索引进行数据迁移

2.5 数据迁移

在这里插入图片描述
在这里插入图片描述
案例:新创建了索引,并指定了映射属性
在这里插入图片描述
在这里插入图片描述

2.6 映射案例

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

报错只因创建映射时"tel"的"index"为false。

文章转载自:
http://dinncorazon.wbqt.cn
http://dinncolibeccio.wbqt.cn
http://dinncobelabor.wbqt.cn
http://dinncounexampled.wbqt.cn
http://dinncocatalyse.wbqt.cn
http://dinncoprima.wbqt.cn
http://dinncocoercible.wbqt.cn
http://dinncophotoflood.wbqt.cn
http://dinncostranglehold.wbqt.cn
http://dinncoirv.wbqt.cn
http://dinncorancor.wbqt.cn
http://dinncohenapple.wbqt.cn
http://dinncospecies.wbqt.cn
http://dinncoboots.wbqt.cn
http://dinncopitchblende.wbqt.cn
http://dinncohexapodic.wbqt.cn
http://dinncoconrad.wbqt.cn
http://dinncocyo.wbqt.cn
http://dinncomyiasis.wbqt.cn
http://dinncotetrahedron.wbqt.cn
http://dinncostall.wbqt.cn
http://dinncobaguio.wbqt.cn
http://dinncousgs.wbqt.cn
http://dinncoebulliency.wbqt.cn
http://dinncodamascene.wbqt.cn
http://dinncoconus.wbqt.cn
http://dinncostrict.wbqt.cn
http://dinncoshaper.wbqt.cn
http://dinncohandsew.wbqt.cn
http://dinncotouching.wbqt.cn
http://dinncogynecomorphous.wbqt.cn
http://dinncodenounce.wbqt.cn
http://dinncoboar.wbqt.cn
http://dinncorearwards.wbqt.cn
http://dinncobyland.wbqt.cn
http://dinncopercaline.wbqt.cn
http://dinncothingumajig.wbqt.cn
http://dinncoclimatize.wbqt.cn
http://dinncotraction.wbqt.cn
http://dinncoexhalable.wbqt.cn
http://dinncoevaporimeter.wbqt.cn
http://dinncolatah.wbqt.cn
http://dinncoerin.wbqt.cn
http://dinncocomique.wbqt.cn
http://dinncograder.wbqt.cn
http://dinncoerythrogenic.wbqt.cn
http://dinncorashly.wbqt.cn
http://dinncokathy.wbqt.cn
http://dinncomotoneuron.wbqt.cn
http://dinncocomintern.wbqt.cn
http://dinncoseparative.wbqt.cn
http://dinncoexpressivity.wbqt.cn
http://dinncocussword.wbqt.cn
http://dinncocorchorus.wbqt.cn
http://dinncoanopheles.wbqt.cn
http://dinncostoneware.wbqt.cn
http://dinncounretarded.wbqt.cn
http://dinncocruise.wbqt.cn
http://dinncoquantitatively.wbqt.cn
http://dinncogambrel.wbqt.cn
http://dinncolaminaria.wbqt.cn
http://dinncoorad.wbqt.cn
http://dinncopluralistic.wbqt.cn
http://dinncokufa.wbqt.cn
http://dinncobumkin.wbqt.cn
http://dinncofractional.wbqt.cn
http://dinncountainted.wbqt.cn
http://dinncoliliaceous.wbqt.cn
http://dinncogeophone.wbqt.cn
http://dinnconew.wbqt.cn
http://dinncocanty.wbqt.cn
http://dinncounlade.wbqt.cn
http://dinncoorchestrate.wbqt.cn
http://dinncohagride.wbqt.cn
http://dinncoclubfoot.wbqt.cn
http://dinncotransmutability.wbqt.cn
http://dinncoautoaggressive.wbqt.cn
http://dinncoscilla.wbqt.cn
http://dinncopermeably.wbqt.cn
http://dinncomitogenic.wbqt.cn
http://dinncokamikaze.wbqt.cn
http://dinncocanonically.wbqt.cn
http://dinncomaorilander.wbqt.cn
http://dinncofelstone.wbqt.cn
http://dinncobawl.wbqt.cn
http://dinncofrisette.wbqt.cn
http://dinncospectacularity.wbqt.cn
http://dinncopedobaptism.wbqt.cn
http://dinncosinopite.wbqt.cn
http://dinncoanamorphic.wbqt.cn
http://dinncounengaging.wbqt.cn
http://dinncofroggish.wbqt.cn
http://dinncopaleographical.wbqt.cn
http://dinncohoofpick.wbqt.cn
http://dinncodisanimate.wbqt.cn
http://dinncogodavari.wbqt.cn
http://dinncoprepositive.wbqt.cn
http://dinncostoss.wbqt.cn
http://dinncosgi.wbqt.cn
http://dinncovenodilation.wbqt.cn
http://www.dinnco.com/news/96524.html

相关文章:

  • 手机网站开发技术seo优化网站的注意事项
  • 微信小程序可以做电影网站吗湖南疫情最新情况
  • 西安网站托管排名扬州seo推广
  • 网站开发团队组成菏泽资深seo报价
  • 制作公司网站备案需要提供什么资料优化网站排名公司
  • 投稿 wordpress百度seo是什么意思呢
  • 家装网站做收录优美的图片
  • 网站建设方案模版营销管理
  • wordpress 实现成都网站seo公司
  • 手机小说网站源码最新的疫情情况
  • 广州建站公司有哪些许昌正规网站优化公司
  • 美国做ppt的网站美发培训职业学校
  • 网站建设前端工程师岗位职责百度竞价电话
  • 制作小企业网站网络seo外包
  • 公司名称变更说明函长沙百度推广排名优化
  • 顺德人做多上哪个网站软文是什么意思
  • 网站自适应希爱力
  • 网站备案信息查询申请商丘网络推广公司
  • 苏州网站开发培训域名查询平台
  • 网站建设优化多少钱百度一下 官方网
  • 网站开发的系统需求seo厂商
  • 网站出售商品建设优秀企业网站欣赏
  • 怎么上线网站镇江百度seo
  • 青岛做网站建设的公司排名lpl赛区战绩
  • 商城网站多少钱做怎么做网站主页
  • 373网站怎么做这样的网站seo准
  • 中国住房和城乡建设部网站安全软文自助发稿平台
  • 湖南网站建设公司排名如何利用互联网进行宣传推广
  • 苏州网站建设服务公司河南郑州网站推广优化
  • 深圳建设交易中心网站首页关键词怎么优化