elasticsearch 常用命令(一)
索引 搜索 mapping 分词器
1.创建索引
http://192.168.65.131:9200/smartom_index?pretty
2.查看索引:
http://192.168.65.131:9200/_cat/indices?v
3.插入数据【这样也就是说创建了一个文档为users】
http://192.168.65.131:9200/smartom_index/users/101
{
"name":"smartom",
"age":19
}
4.精确搜索
http://192.168.65.131:9200/smartom_index/_search?q=name:smartom
5.全词搜索
http://192.168.65.131:9200/smartom_index/_search
全文索引
6.全词搜索 term
term是代表完全匹配,即不进行分词器分析,文档中必须包含整个搜索的词汇
GET smartom_index/users/_search
{
"query":{
"term":{
"name":{
"value":"smartom"
}
}
}
}
7.全词搜索 match 全文搜索查询
分词查询
GET smartom_index/users/_search
{
"query": {
"match": {
"name": "我是smartom你是谁"
}
}
}
分词器analyze
8.创建一个分词器
POST _analyze
{
"analyzer":"standard",
"text":"我是smartom你是谁"
}
standard
simple
过滤器 标记器
9. 一个标记器【filter?】
POST _analyze
{
"tokenizer":"lowercase",
"text":"SMARTOM"
}
也可以 在tokenizer里面写 standard
10.一个过滤器:
POST _analyze
{
"tokenizer": "standard",
"filter": ["lowercase"],
"text": "我是smartom你是谁"
}
11.字符过滤器:[过滤html代码]
POST _analyze
{
"tokenizer": "standard",
"char_filter": ["html_strip"],
"text": "woshi<br><b>asdf</b>是"
}
12.创建一个过滤器:settings analysis analyzer
PUT smartom
{
"settings": {
"analysis": {
"analyzer": {
"smartom-analyer":{
"type":"custom",
"tokenizer":"standard",
"char_filter":["html_strip"],
"filter":["lowercase"]
}
}
}
}
}
13.创建仓库:
前提指定repo路径 elasticsearch.yml path.repo path.repo:["/home/smartom/Desktop/esbak"]
PUT _snapshot/mybackup
{
"type": "fs",
"settings": {
"location": "/home/smartom/Desktop/esbak"
}
}
14.备份索引:
bak1 是备份名称 smartom_index 备份的索引名称
PUT _snapshot/mybackup/bak1?wait_for_completion=true
{
"indices": "smartom_index"
}
15.删除索引
DELETE smartom
16.关闭索引
POST smartom_index/_close
17.恢复索引
POST _snapshot/mybackup/bak1/_restore?wait_for_completion=true
{
"indices": "smartom_index"
}
18.查看当前插件
GET _cat/plugins
19.查看mapping当前文档 查看文档字段类型?
GET smartom_index/_mappings
20.创建mapping
[刚创建的时候]
POST /smartom_index/fulltext/_mapping
{
"properties": {
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
}
}
}
需要导入和导出数据
删除数据之后 title 用ik分词器进行索引
PUT smartom_index
{
"mappings": {
"news":{
"properties": {
"title": {
"type":"text",
"analyzer": "ik_max_word"
}
}
}
}
}
21.修改文档中的类型?
PUT smartom_index/_mapping/users
{
"properties": {
"news": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
22.搜索建议
elasticsearch 常用命令(一)的更多相关文章
- elasticsearch常用命令
elasticsearch的rest访问格式: curl -X<REST Verb> <Node>:<Port>/<Index>/<Type> ...
- elasticsearch 常用命令
#查看集群状态 curl -XGET "http://localhost:9200/_cluster/health?pretty" #查看所有的快照 curl -XGET &quo ...
- 实战ELK(2) ElasticSearch 常用命令
1.Cluster Health 集群状态 curl 'localhost:9200/_cat/health?v' yellow代表分片副本确实,因为我们现在只有一台机器. curl 'localho ...
- elasticsearch 常用命令 一直红色 重启不稳定 不停的宕机
persistent (重启后设置也会存在) or transient (整个集群重启后会消失的设置). 查看集群状态和每个indices状态.搜索到red的,没用就删除 GET /_cluster/ ...
- ElasticSearch——常用命令
集群相关 --查询集群健康状态 GET _cluster/health --查询所有节点 GET _cat/nodes --查询索引及分片的分布 GET _cat/shards --查询指定索引分片的 ...
- elasticsearch常用命令备注
1.检查集群健康状态 curl 'localhost:9200/_cat/health?v' 2.检查节点健康状态 curl 'localhost:9200/_cat/nodes?v' 3.新增一条索 ...
- elasticsearch(四) 之 elasticsearch常用的一些集群命令
目录 elasticsearch常用的一些集群命令 查看集群健康状态 查看集群的节点列表 查看所有的索引 删除索引 查询索引的某个文档内容 更新文档 删除文档 自动创建索引 定时删除索引 elasti ...
- elasticsearch 索引清理脚本及常用命令
elastic索引日志清理不及时,很容易产生磁盘紧张,官网给出curl -k -XDELETE可以清理不需要的索引日志. 清理脚本 #!/bin/bash #Author: 648403020@qq. ...
- Docker安装和常用命令
Docker安装 Docker的安装可以参考 https://docs.docker.com/ 下面的 Get Docker / Docker CE / Linux, 需要关注的主要是CentOS和U ...
随机推荐
- JAVA接口传递参数(POST),从接口接收数据(JSON) -----记录
1,给接口传递json格式的数据 import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOEx ...
- Java 经典面试题 —— 性能
1. 性能 String.StringBuffer 与 StringBuilder 两个字符串相加,str1+str2,相当于执行: StringBuilder strBuilder1 = new S ...
- directive例子1
(function() { 'use strict'; angular.module('app.widgets') .directive('confirm', ['confirm2', 'toastr ...
- [LeetCode&Python] Problem 383. Ransom Note
Given an arbitrary ransom note string and another string containing letters from all the magazines, ...
- manjaro初体验
manjaro Linux是https://distrowatch.com/网站上排名第一的Linux分支. https://manjaro.org/ 选择,下载,打开主页下载页:https://ma ...
- Blender设置界面语言
新安装的Blender默认是英文, 可通过如下方法修改界面语言: 1. 点开文件菜单{File},选择用户首选项{User Preferences}: 2. 在用户首选项{User Preferenc ...
- (19)jQuery操作文本和属性
<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>jq ...
- oracle 数据库备份、还原、和使用心得(表丢失、视图丢失的解决办法)
一.oracle数据备份:exp 关键字 说明(默认值) 关键字 说明(默认值) --------------------------------- ...
- Go Example--定时器
package main import ( "fmt" "time" ) func main() { //定时器2s timer1 := time.NewTim ...
- 通信协议演进与JCE协议详解
一.通信协议概述通信协议是两个节点之间为了协同工作.实现信息交换,而协商的规则和约定,例如规定字节序,各个字段类型,使用什么压缩算法或加密算法等. 1.原始数据假设A和B通信,获取或设置用户基本资料, ...