白手起家之搜索利器ELastic search

这是我参与8月更文挑战的第7天,活动详情查看:8月更文挑战css

基于开源的分布式,全文搜索引擎:html

ELastic searchmysql

官网: www.elastic.co/cn/sql

image.png

下载:www.elastic.co/cn/download…数据库

image.png

主要是用于数据的搜索,动态的查询.数据的过滤等';浏览器

数据分为:markdown

   结构化数据的,二维表的形式网络

  非结构化的数据,图标elasticsearch

  半结构化的数据 html,css.等语言信息分布式

开始下载:

下载完成以后解压缩:

image.png

image.png

image.png

http://localhost:9200     9200是一个客户端的启动端口

9300 端口为 Elasticsearch 集群间组件的通讯端口,9200 端口为浏览器访问的 http

议 协议 RESTful 端口。

image.png

表示启动完成

image.png

将bin/elssticSearche.bat而后将数据请求一个地址  http://localhost:9200

image.png

es启动成功 ,表示Elastic search成功启动;

es 遵照RESTful原则的开发,   幂等性一致,可是post不是

资源的转化,请求;

JSON格式

Javascript object  notation

var obj={ "name":"lucas"}`
复制代码

JSON字符串:表示网络中传递的字符串的格式符合JSON格式

倒排索引:

image.png

es基础操做:

image.png

建立一个index(mysql中的数据库database)

  

建立索引:(发生put请求)

 

http://localhost:9200/shopping     put请求表示建立,具体要幂等性,屡次建立同名的都会是同一个,es中对于
复制代码

es对于索引,支持Get(获取),put(建立),delete(删除),

image.png

  image.png

image.png

查看当前索引的信息:

http://localhost:9200/shopping
复制代码

image.png

复制代码

查询一下所有索引的信息:

image.png

http://localhost:9200/_cat/indices?v
复制代码

删除当前的索引:

http://localhost:9200/shopping
复制代码

 image.png

建立文档:

 

http://localhost:9200/shopping/_doc
复制代码

image.png  

image.png

{
    "title": "小米手机",
    "category": "小米",
    "images": "http://www.gulixueyuan.com/xm.jpg",
    "price": 3999.00
}
 

复制代码

image.png

{
"_index"【索引】: "shopping",
"_type"【 类型-文档 】: "_doc",
"_id"【惟一标识】: "Xhsa2ncBlvF_7lxyCE9G", #能够类比为 MySQL 中的主键,随机生成
"_version"【版本】: 1,
"result"【结果】: "created", #这里的 create 表示建立成功
"_shards"【分片】: {
"total"【分片 - 总数】: 2,
"successful"【分片 - 成功】: 1,
"failed"【分片 - 失败】: 0
},
"_seq_no": 0,
"_primary_term": 1
}

复制代码

  上文有个惟一的标识; 也能够自定义完成,基于

 

http://localhost:9200/shopping/_doc/1001    post
复制代码
http://localhost:9200/shopping/create/1002   put
复制代码

查看你文档数据:

http://localhost:9200/shopping/_doc/1001   get
复制代码

image.png

如何查询当前索引下所有的文档信息:  

http://localhost:9200/shopping/_search
复制代码

image.png

put/ 是全量更新

post是局部更新;

image.png

删除文档:

image.png

image.png

相关文章
相关标签/搜索