# ElasticSearch **Repository Path**: zhanglibin/ElasticSearch ## Basic Information - **Project Name**: ElasticSearch - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-04-24 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ElasticSearch [安装完启动可能会有报错的相关连接解决办法链接](https://blog.csdn.net/feng12345zi/article/details/80367907) #### 如果你想把 Elasticsearch 作为一个守护进程在后台运行,那么可以在后面添加参数 -d 。 #### 中文文档[文档连接](https://es.xiaoleilu.com/010_Intro/30_Tutorial_Search.html) ## 安装步骤 1. 安装jdk1.8版本以上,环境变量配置好 2. 下载安装包 `wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.0.tar.gz` 3. 解压 tar zxvf 要解压的压缩包 4. 解压完目录结构 ![输入图片说明](https://gitee.com/uploads/images/2019/0424/095700_39a895c0_1279062.png "WX20190424-095617@2x.png") 5. 修改配置文件config/elasticsearch.yml。代表任何ip都可以访问 ![输入图片说明](https://gitee.com/uploads/images/2019/0424/095919_b22266ec_1279062.png "WX20190424-095840@2x.png") 6. 安装分词插件,和es版本对应,参考地址`https://github.com/medcl/elasticsearch-analysis-ik/` 7. 安装命令`./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.6.0/elasticsearch-analysis-ik-6.6.0.zip` 8. 启动,启动命令如下:./bin/elasticsearch。出现如下图,表示成功 ![输入图片说明](https://gitee.com/uploads/images/2019/0424/100947_f2b417ed_1279062.png "图片9.png") 9. 浏览器输入ip:9200。可以看到版本等一些详情 ![输入图片说明](https://gitee.com/uploads/images/2019/0424/101105_3b104fe9_1279062.png "WX20190424-101052@2x.png") 10. 单个插入命令 ``` curl -H 'Content-Type: application/json' -X PUT "http://localhost:9200/movies/movie/1" -d' { "title": "张丽宾", "director": "哈哈哈啊哈哈", "year": 1222 }' ``` 11. 更新操作和插入一样 12. 删除操作 ``` curl -X DELETE 'localhost:9200/accounts/person/1' ``` 13. 查看命令 ``` $ curl 'localhost:9200/accounts/person/1' ``` 14. 查看指定类型下的所有数据 ``` curl 'localhost:9200/accounts/person/_search' ``` 15. 关键字查询 ``` curl -H 'Content-Type: application/json' 'localhost:9200/accounts/person/_search' -d ' { "query" : { "match" : { "desc" : "软件" }}, "size" : 10 }' ``` 16. 关键字 or 查询 ``` curl -H 'Content-Type: application/json' 'localhost:9200/accounts/person/_search' -d ' { "query" : { "match" : { "desc" : "软件 系统" }}, "size" : 10 }' ``` 17. 查询每页规定多少数量。可以这样 . q=query 查询title中包含99的内容 ``` http://172.30.10.2:9200/movies/movie/_search?size=10&q=title:99 ```