美文网首页
ElasticSearch安装和入门

ElasticSearch安装和入门

作者: hk_faith | 来源:发表于2019-02-19 19:54 被阅读0次

ElasticSearch 的docker安装

docker pull elasticsearch:6.6.0
docker network create somenetwork
docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:6.6.0

访问:http://localhost:9200

kibana安装

docker pull kibana:6.6.0
docker run -d --name kibana --net somenetwork -p 5601:5601 kibana:tag

访问:http://localhost:5601

与关系型数据库的对比

关系型数据库---数据库---表--行---行
elasticSearch---Index(索引)---Type(类型)--Documents(文档)---Fields(属性)

根据规划,Elastic 6.x 版只允许每个 Index 包含一个 Type,7.x 版将会彻底移除 Type。es是一个面向文档的数据库,他侧重于搜索。1.索引是一类文档的集合,es的一些操作都是基于索引来进行的。type类型,可以理解为索引的一个逻辑分区,es是以索引为粗粒度单位,如果一个索引下有多个类型,会造成不同类型的相同的字段类型冲突问题。

简单使用

查看安装成功
http://localhost:9200
查看当前节点的所有的Index
http://localhost:9200/_cat/indices?v
列出每个 Index 所包含的 Type
http://localhost:9200/_mapping?pretty=true
创建Index
put  http://localhost:9200/_index
删除Index
delete  http://localhost:9200/_index
查看Index信息
get  http://localhost:9200/_index
创建指定ID的 documents
put  http://localhost:9200/_index/_type/1
       
 { "name": "_name",
  "title": "_title",
  "desc": "_desc"  } 
 
创建指定ID的 documents
post  http://localhost:9200/_index/_type
       
 { "name": "_name",
  "title": "_title",
  "desc": "_desc"  } 

获取一条document
get  http://localhost:9200/_index/_type/_id
更新 documents
put  http://localhost:9200/_index/_type/_id
       
 { "name": "_name",
  "title": "_title",
  "desc": "_desc"  } 
 
删除一条document
deletehttp://localhost:9200/_index/_type/_id
获取Index中的Type所有的documents
get  http://localhost:9200/_index/_type/_search
全文搜索 match 语法
get  http://localhost:9200/_index/_type/_search
      {
  "query" : { "match" : { "desc" : "_desc" }}
    }

相关文章

网友评论

      本文标题:ElasticSearch安装和入门

      本文链接:https://www.haomeiwen.com/subject/tjcgeqtx.html