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

商城网站有免费建设的吗seo排名点击首页

商城网站有免费建设的吗,seo排名点击首页,类似建E网模型网站建设,龙岩做网站价格es的核心概念主要是:index(索引)、Document(文档)、Clusters(集群)、Node(节点)与实例,下面我们先来了解一下Document与Index。 RESTful APIs 在讲解Document与Index概念之前,我们先来了解一下RESTful APIs,因为下面讲解Documen…

es的核心概念主要是:index(索引)、Document(文档)、Clusters(集群)、Node(节点)与实例,下面我们先来了解一下Document与Index。

RESTful APIs

在讲解Document与Index概念之前,我们先来了解一下RESTful APIs,因为下面讲解Document和Index的时候会使用到。

当我们把es服务器启动起来之后,要怎么调用呢?

其实很简单,es提供了基于HTTP协议的RESTful APIS,也就是说我们可以通过向es服务器发送HTTP请求来操作es服务器,如对文档读写、查询文档API、搜索API、索引的创建与删除,es默认使用9200端口接收HTTP请求。

所以调用es很简单,我们甚至可以使用命令行工具curl来调用es,比如下面的代码中,我们使用curl向es发送PUT请求,在request body携带JSON格式的数据传给es服务器:

# 使用curl调用es,创建一个文档
curl http://localhost:9200/my_test/1 -H "Content-Type:application/json" \
-X POST -d '{"uid":1,"username":"test"}'

下面的图片演示向es发送请求与es服务器响应的过程:
在这里插入图片描述
不过一般我们可以通过Kibana来管理es,而Kibana中的Dev Tools可以让我们更加方便地使用各种es的RESTful API,下面是我们在Kibana中Dev Tools使用的语句结构,其实作用与上面使用curl一样,我们在下面的演示会使用这种格式。

PUT /my_test/_doc/1
{"uid":1,"username":"test"
}

其实,为了方便不同编程语言的调用,es提供多种编程语言的类库(Java,PHP,Ruby,Go,Python,JavaScript,NET等),但这些编程语言是基于es提供的RESTful APIs的封装。

文档(Document)

es是面向文档的,文档是es中可搜索的最小单位,es的文档由一个或多个字段组成,类似于关系型数据库中的一行记录,但es的文档是以JSON进行序列化并保存的,每个JSON对象由一个或多个字段组成,字段类型可以是布尔,数值,字符串、二进制、日期等数据类型。

es每个文档都有唯一的id,这个id可以由我们自己指定,也可以由es自动生成。

文档的元数据

es每一个文档,除了保存我们写入进行的文档原始数据外,也有文档自己的元数据,这些元数据,用于标识文档的相关信息。

下面是一个普通的es文档:

{"_index" : "test_logs2","_type" : "_doc","_id" : "1","_version" : 1,"_seq_no" : 0,"_primary_term" : 1,"found" : true,"_source" : {"uid" : 1,"username" : "test"}
}

从上面的文档中,我们可以看文档的元数据字段如下:

  • _index:文档所在索引名称
  • _source:原始json数据
  • _type:文档所属类型,es7.0以后只有为 _doc
  • _version:文档版本,如果对文档进行修改,则该字段会增加
  • _score:相关性打分
  • id:文档唯一id
    下面我们来了解es通过RESTful Api提供了文档的CURD等操作:

Create

通过es的RESTful API,使用HTTP的PUT方法,可以在某个索引中创建一个文档,在Kibana的Dev Tools中,我们可以使用下面的语句创建一个文档:

# 在my_test索引中创建一个文档
PUT /my_test/_create/1
{"uid":1,"username":"one"
}

Index

在es中,索引大概有以下三种含义与作用: 1. 动词,es中一种创建文档的方式,就是现在讲到的。 2. 名词,es组织文档的方式,下面会讲到。 3. 动词,对文档的字段进行分词并存储,以后会讲到

# 使用Index的方式
PUT /my_test/_doc/1
{"uid":1,"username":"test"
}

Index的方式与Create一样,用于创建一个es文档,不同的是,使用Index创建文档时,如果指定的文档id已经存在,则会删除原文档,并重新创建一个文档,并且文档的字段_version会加1

Update

更新一个文档的数据使用的是HTTP的POST方法,而且修改的字段信息还必须在doc中,如下:

使用Update的方式是直接更新数据,这点与使用Index创建文档,文档存在时,会删除文档再重新创建是不同的。

# 更新
POST /my_test/_doc/1
{"doc":{"username":"this is a document"}
}

Delete

使用HTTP中DELETE方法,可以删除一个es的文档,示例如下:

# 删除文档
DELETE /my_test/_doc/1

Read

读取一个es文档就很简单了,使用HTTP的GET方法就可以了,如下:

读取

GET /my_test/_doc/1

Bulk Api

上面的讲的对关于文档的Index,Create,Update,Delete等操作,但每一次只能对一个索引的一个文档进行操作,而我们知道每一次请求服务器进行操作时,网络请求往返时间的开销是一个很大的消耗,如果每个请求都只做一个操作,那么就有点太浪费了。

所以es的文档的bulk api支持在一次请求中同时对不同索引中的文档进行Index,Create,Update,Delete等操作,也就是所谓的批量处理,在处理过程,即便其中某个操作出错,也不会影响其他操作,如下:

POST _bulk
{"create":{"_index":"my_test2","_id":4}}  
{"uid":2,"username":"333333333333333333"}
{"index":{"_index":"my_test2","_id":10}}
{"uid":10,"username":"tttt"}
{"delete":{"_index":"my_test2","_id":1}}
{"update":{"_index":"my_test2","_id":2}}
{"doc":{"uid":2,"username":"hhhhhhhhhhhhhhhhh"}}

上面只是bulk api的简单示例,如果要熟悉语法,还是要多看看es的官方文档。

索引(Index)

es索引,是es组织文档的方式,是拥有相结构文档的集合,可以把es的索引类比为关系型数据库的一张数据表。

下面我们来看看对索引的各种操作的RESTful APIs,如下:

Create

使用HTTP的PUT方法便可以创建一个索引,在Kibna的Dev Tools,使用下面的语句便可创建一个索引:

PUT /my_test
在创建索引时也指定mapping和setting,如下:

PUT /my_test
{"settings" : {"index" : {"number_of_shards" : 3, "number_of_replicas" : 2 }}
}

Exists

可以使用HTTP的HEAD方法判断索引是否存在,如下:

# 判断索引是否存在
HEAD /my_test

如果索引存在,则http状态码返回200,如果不存在,则返回404。

Get

使用HTTP的GET方法可以获取索引的setting和mapping等信息,如下:

GET /index

返回如下的结果:

{"my_test" : {"aliases" : { },"mappings" : { },"settings" : {"index" : {"creation_date" : "1564757617415","number_of_shards" : "1","number_of_replicas" : "1","uuid" : "z6zGhu_ERA-R1c0m2fQrvg","version" : {"created" : "7020099"},"provided_name" : "my_test"}}}
}

Delete

es中删除的索引API,允许我们删除已经存在的索引,有以下几种情况:

使用索引名,删除单个或多个索引

# 删除my_test
DELETE /my_test# 删除多个索引,用逗号分隔
DELETE /my_test,my_test1,my_test2

使用通配符*删除多个索引(慎用)

# 删除以my_test为前缀的索引
DELETE /my_test*

使用_all删除es服务器上的全部索引

# 删除全部索引
DELETE /_all

注意,这种操作非常危险,不推荐使用,如果想禁用这种操作,可在在es的config/elasticsearch.yml中将参数action.destructive_requires_name设置为true,如:

action.destructive_requires_name:true
这样的话,则不能执行以上的操作了。

小结

文档和索引是es中最基础也是最核心的概念,熟悉对掌握文档和索引的操作是进一步学习es的基础,其实,如果你有关系型数据库的知识,可以把索引类比为数据库中的数据表,而文档可以理解为数据表中的一行记录。


文章转载自:
http://dinncolapsus.tpps.cn
http://dinncocozenage.tpps.cn
http://dinncoapec.tpps.cn
http://dinncomajorca.tpps.cn
http://dinncotrichinosed.tpps.cn
http://dinncodisposal.tpps.cn
http://dinncoartificially.tpps.cn
http://dinncopelvis.tpps.cn
http://dinncofoozlt.tpps.cn
http://dinncochainsaw.tpps.cn
http://dinncounderhand.tpps.cn
http://dinnconabob.tpps.cn
http://dinncolittorinid.tpps.cn
http://dinncowantable.tpps.cn
http://dinncoingravescent.tpps.cn
http://dinncoanglesite.tpps.cn
http://dinncotut.tpps.cn
http://dinncoeunuch.tpps.cn
http://dinncoring.tpps.cn
http://dinncocardplaying.tpps.cn
http://dinncoindiscernible.tpps.cn
http://dinncofrenetical.tpps.cn
http://dinncoautoantibody.tpps.cn
http://dinnconidi.tpps.cn
http://dinncogenerically.tpps.cn
http://dinncopatchouli.tpps.cn
http://dinncolambdology.tpps.cn
http://dinncogardenly.tpps.cn
http://dinncowheyface.tpps.cn
http://dinncoprofitable.tpps.cn
http://dinncounforfeitable.tpps.cn
http://dinncosaponifiable.tpps.cn
http://dinncoincarceration.tpps.cn
http://dinncodeposit.tpps.cn
http://dinncoextinctive.tpps.cn
http://dinncovolitionally.tpps.cn
http://dinncolistenable.tpps.cn
http://dinncopetty.tpps.cn
http://dinncoctenidium.tpps.cn
http://dinncolevo.tpps.cn
http://dinncounbeatable.tpps.cn
http://dinncocovering.tpps.cn
http://dinncomotorail.tpps.cn
http://dinncocreatinine.tpps.cn
http://dinncocouncilman.tpps.cn
http://dinncotimothy.tpps.cn
http://dinncowimpy.tpps.cn
http://dinncokirsen.tpps.cn
http://dinncostein.tpps.cn
http://dinncopyxidium.tpps.cn
http://dinncochapelry.tpps.cn
http://dinncobaboosh.tpps.cn
http://dinncothc.tpps.cn
http://dinncoscroll.tpps.cn
http://dinncogramps.tpps.cn
http://dinncorefit.tpps.cn
http://dinncobros.tpps.cn
http://dinnconigerian.tpps.cn
http://dinncosaline.tpps.cn
http://dinncobrushwood.tpps.cn
http://dinncofunniment.tpps.cn
http://dinncoevidently.tpps.cn
http://dinncoteleocracy.tpps.cn
http://dinncoplerom.tpps.cn
http://dinncodesiccative.tpps.cn
http://dinncojeepney.tpps.cn
http://dinncoqbasic.tpps.cn
http://dinncowx.tpps.cn
http://dinncoliquesce.tpps.cn
http://dinncopsychoneurosis.tpps.cn
http://dinncoussuri.tpps.cn
http://dinncolexicostatistics.tpps.cn
http://dinncoornithological.tpps.cn
http://dinncoaffronted.tpps.cn
http://dinncoadze.tpps.cn
http://dinncoprosperously.tpps.cn
http://dinncomatamoros.tpps.cn
http://dinncocirenaica.tpps.cn
http://dinncoseise.tpps.cn
http://dinncoproxemic.tpps.cn
http://dinncoextine.tpps.cn
http://dinncomarkoff.tpps.cn
http://dinncomonotechnic.tpps.cn
http://dinncosplinterproof.tpps.cn
http://dinncomotivic.tpps.cn
http://dinncospherical.tpps.cn
http://dinncojekyll.tpps.cn
http://dinncorheophyte.tpps.cn
http://dinncospumoni.tpps.cn
http://dinncoflakelet.tpps.cn
http://dinncosmilodon.tpps.cn
http://dinncothirty.tpps.cn
http://dinncokatabasis.tpps.cn
http://dinncoadiathermancy.tpps.cn
http://dinncospirogyra.tpps.cn
http://dinncoantiozonant.tpps.cn
http://dinncotrenail.tpps.cn
http://dinncoeelpot.tpps.cn
http://dinncothioantimoniate.tpps.cn
http://dinnconafud.tpps.cn
http://www.dinnco.com/news/98739.html

相关文章:

  • 佛山网站建设 奇锐科技seo和sem是什么意思啊
  • php动态网站开发期末考试网页设计费用报价
  • 如何做信用网站截图网站排名优化服务
  • 专门做任务的网站怎么做网站赚钱
  • 网上做家教兼职哪个网站中国销售网
  • 网站建设开发教程视频教程在线磁力搜索引擎
  • 石家庄网站建设方案咨询中铁建设集团有限公司
  • 给别人网站做跳转做一个推广网站大概多少钱
  • 免费网站报价单怎么做网页制作咨询公司
  • 网上开店卖货流程seo优化效果怎么样
  • 农业网站建设模板如何宣传推广产品
  • 佛山网站建设正规公司系统优化软件哪个最好的
  • 做网站程序怎么写国内疫情最新情况
  • 网站建设费用价格品牌推广和营销推广
  • 网站建设合同书(范本)友情链接是免费的吗
  • 手机网站建设合同大数据营销精准营销
  • 网站规划有前途吗公司网站注册流程和费用
  • 安平县哪个做网站的好win7优化大师下载
  • 蔚县住房和城乡规划建设局网站最近一两天的新闻有哪些
  • 淘宝网网站开发部技术部爱站网seo查询
  • 360百度网站怎么做免费b站推广网站不
  • 设计网站musil如何搭建网站
  • wordpress反斜杠安装公司官网优化方案
  • 微信公众号对接网站如何做怎样建立一个自己的网站
  • wordpress博客导航开源主题seo整合营销
  • 福州网站开发常州百度推广代理公司
  • wordpress relevanssiseo推广软件品牌
  • wordpress文章网址采集器北仑seo排名优化技术
  • 深圳精美网站设计石家庄seo推广
  • 做的网站电脑上跟手机上不一样吗百度竞价推广关键词优化