ElasticSearch入门常用命令
基于开源项目MyAlice智能客服学习ElasticSearch
https://github.com/hpgary/MyAlice/wiki/%E7%AC%AC01%E7%AB%A0%E5%AE%89%E8%A3%85
首先和常用的关系型数据库做一个对比,明确一下概念:
| EslaicSearch | MySQL |
| 索引 | 数据库 |
| type | 表 |
| document | 行 |
| filed | 列 |
HEAD 插件安装:
./bin/plugin install mobz/elasticsearch-head
访问:http://localhost:9200/_plugin/head/
可以通过此插件创建、删除索引、查看索引状态、统计信息、开启/关闭索引、刷新、优化索引;测试分析器;
1、查看集群
http://localhost:19200/
2、查看文档数量
http://localhost:19200/_count?pretty
3、查看健康状态
http://localhost:19200/_cat/health?v
4、查看节点信息
http://localhost:19200/_cat/nodes?v
5、查看索引
http://localhost:19200/_cat/indices?v
6、查看索引下的类型
http://localhost:19200/myalice
对应的mappings字段里面的字段名称就是类型(相当于数据库中的表)
7、列出某索引 类型 下的文档
http://localhost:19200/myalice/question/_search
question是类型
8、在类型中根据title搜索
http://localhost:19200/myalice/question/_search?q=title:%E5%90%83
其中title是文档字段
9、新建type插入文档
curl -XPUT 'localhost:19200/myalice/word/1' -d'{"word":"此外"}'
10、复杂查询
curl -XGET 'localhost:19200/myalice/word/_search?pretty' -d '{"query":{"match":{"text":"此外"}}}'
11、match 和 term的区别
term 不会对搜索词分词,会将带搜索的文档分词,然后将term和分词匹配!
match 会对搜索词分词,也会对搜索的文档分词,两个有交集即可
12、删除数据
curl -XDELETE 'http://localhost:9200/twitter/tweet/1'
安装 delete by query插件:
./bin/plugin install delete-by-query curl -H "Content-Type: application/json" -XDELETE localhost:9200/uploaddata/uploaddata/_query -d '{"query":{"range":{"createTimeStamp":{"lte":1520611200000}}}}' 13、设置最大查询数目(其中rowkeys是索引名称)
curl -XPUT http://10.38.161.138:9200/rowkeys/_settings -d '{ "index" : { "max_result_window" : 100000000}}'
14、删除索引
curl -XDELETE http://localhost:9200/traindata
15、查看内存占用等指标
http://host:9200/_cat/nodes?v&h=host,heap.current,heap.percent,heap.max,ram.max,disk.avail,node.role,m
16、post查询
curl -H "Content-Type: application/json" -XPOST localhost:9200/uploaddata/_search?pretty=true -d '{"query":{"term":{"pushId":"adm03109522050226131h"}}}'
17、关闭/打开索引:
curl -XPOST http://localhost:9200/sms0/_close
curl -XPOST http://localhost:9200/sms0/_open
ElasticSearch入门常用命令的更多相关文章
- docker入门-常用命令和网络
一.常用命令 容器生命周期管理 run 运行一个容器 start/stop/restart 启动/停止/重启 kill 杀死一个容器 rm 删除一个容器 pause/unpause c ...
- 使用kibana或postman操作Elasticsearch的常用命令
前言服务器:CentOS-6.7 运行系统:windows10 JDK版本:1.8 Elasticsearch版本:5.6.6 插件:kibana.elasticsearch-head 工具:post ...
- Oracle 学习笔记2:几个入门常用命令
oracle提供的交互方式有两种:sqlplus(命令行) sqlplusw(图形界面) 进入sqlplus方式:cmd中输入sqlplus 进入sqlplusw方式:cmd中输入sqlplusw 更 ...
- git 入门常用命令(转)
Git工作流程:D:\projects\Setup2\Setup2\Setup2\Express\SingleImage\DiskImages\DISK1 git clone工作开始之初,可通过git ...
- Linux 新手入门常用命令
1,增加用户:useradd mylinux passwd mylinux 添加你的用户密码 2,切换用户: su otheruser (注意这种切换方式只是临时的,本质工作目录还在原来的用户目录 ...
- elasticsearch 管理常用命令集合
elasticsearch rest api遵循的格式为: curl -X<REST Verb> <Node>:<Port>/<Index>/<T ...
- Docker入门-常用命令
Docker镜像操作 Docker运行容器前需要本地存在对应的镜像,如果本地不存在该镜像,Docker会从镜像仓库下载该镜像. 获取镜像 从Docker镜像仓库获取镜像的命令是docker pull. ...
- SSH入门常用命令
一.参考链接大猫的博客
- MongoDB入门 常用命令以及增删改查的简单操作
1,运行MongoDB服务mongod --dbpath=/usr/local/developmentTool/mongo/data/db/然后启动客户端mongo2,sudo service mon ...
随机推荐
- iOS开发常见问题(不断更新)
1.如何从程序退出到桌面 在单击事件中 exit(0);即可. 2.如何强制横屏 在你需要横屏的控制器里加入如下代码 - (BOOL)shouldAutorotate{ return NO; } - ...
- mysql的体系架构和存储引擎
定义数据库和实例 数据库:物理操作系统的文件或其他形式文件类型的集合.在mysql数据库中,数据库文件可以是frm.MYD.MYI.ibd结尾的文件. 实例:MySQL数据库由后台线程以及一个共享内存 ...
- centos6.4下安装mysql5.7.18
1.安装前工作 在安装前需要确定现在这个系统有没有 mysql,如果有那么必须卸载(在 centos7 自带的是 mariaDb 数据库,所以第一步是卸载数据库). 卸载系统自带的Mariadb: 查 ...
- scaffolding —— 脚手架(转)
Scaffolding — 基架 基于数据库架构生成网页模板的过程.在 ASP .NET 中,动态数据使用基架来简化基于 Web 的 UI 的生成过程.用户可以通过这种 UI 来查看和更新数据库. ...
- 【BZOJ2186】[Sdoi2008]沙拉公主的困惑 线性筛素数
[BZOJ2186][Sdoi2008]沙拉公主的困惑 Description 大富翁国因为通货膨胀,以及假钞泛滥,政府决定推出一项新的政策:现有钞票编号范围为1到N的阶乘,但是,政府只发行编号与M! ...
- Censor(KMP)
Censor frog is now a editor to censor so-called sensitive words (敏感词). She has a long text pp. Her j ...
- 借助EasyNTS云组网,无需拉专线,也能解决设备现场无公网固定IP的问题
一.产品背景 为了帮助企业和个人用户解决网络访问和设备控制的问题,我们研发了一款创新型产品:EasyNTS云组网系统.什么是EasyNTS,什么是云组网呢? 在解释之前,我们先来了解几个在凡是涉及网络 ...
- Redis3.2.5配置主从服务器遇到的一些错误
注意:关闭主从服务器的防火墙 问题一: WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net ...
- 外部导入js(javascript)文件方法
<script src="myScript.js"></script>
- PAT 1002. A+B for Polynomials (25)
This time, you are supposed to find A+B where A and B are two polynomials. Input Each input file con ...