索引 搜索 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 常用命令(一)的更多相关文章

  1. elasticsearch常用命令

    elasticsearch的rest访问格式: curl -X<REST Verb> <Node>:<Port>/<Index>/<Type> ...

  2. elasticsearch 常用命令

    #查看集群状态 curl -XGET "http://localhost:9200/_cluster/health?pretty" #查看所有的快照 curl -XGET &quo ...

  3. 实战ELK(2) ElasticSearch 常用命令

    1.Cluster Health 集群状态 curl 'localhost:9200/_cat/health?v' yellow代表分片副本确实,因为我们现在只有一台机器. curl 'localho ...

  4. elasticsearch 常用命令 一直红色 重启不稳定 不停的宕机

    persistent (重启后设置也会存在) or transient (整个集群重启后会消失的设置). 查看集群状态和每个indices状态.搜索到red的,没用就删除 GET /_cluster/ ...

  5. ElasticSearch——常用命令

    集群相关 --查询集群健康状态 GET _cluster/health --查询所有节点 GET _cat/nodes --查询索引及分片的分布 GET _cat/shards --查询指定索引分片的 ...

  6. elasticsearch常用命令备注

    1.检查集群健康状态 curl 'localhost:9200/_cat/health?v' 2.检查节点健康状态 curl 'localhost:9200/_cat/nodes?v' 3.新增一条索 ...

  7. elasticsearch(四) 之 elasticsearch常用的一些集群命令

    目录 elasticsearch常用的一些集群命令 查看集群健康状态 查看集群的节点列表 查看所有的索引 删除索引 查询索引的某个文档内容 更新文档 删除文档 自动创建索引 定时删除索引 elasti ...

  8. elasticsearch 索引清理脚本及常用命令

    elastic索引日志清理不及时,很容易产生磁盘紧张,官网给出curl -k -XDELETE可以清理不需要的索引日志. 清理脚本 #!/bin/bash #Author: 648403020@qq. ...

  9. Docker安装和常用命令

    Docker安装 Docker的安装可以参考 https://docs.docker.com/ 下面的 Get Docker / Docker CE / Linux, 需要关注的主要是CentOS和U ...

随机推荐

  1. 2.23 js处理日历控件(修改readonly属性)

    2.23 js处理日历控件(修改readonly属性) 前言    日历控件是web网站上经常会遇到的一个场景,有些输入框是可以直接输入日期的,有些不能,以我们经常抢票的12306网站为例,详细讲解如 ...

  2. 第三十二课 linux内核链表剖析

    __builtin_prefetch是gcc扩展的,用来提高访问效率,需要硬件的支持. 在标准C语言中是不允许static inline联合使用的. 删除依赖的头文件,将相应的结构拷贝到LinuxLi ...

  3. 【Java】将字节转换成十六进制、BCD码输出

    public class HexUtils { public static void main(String[] args) { byte []out = { 0, 1, 2, 3, 4, 5, 6, ...

  4. GitHub使用教程、注册与安装

    GitHub注册与安装 本文提供全流程,中文翻译.Chinar坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请调整网页缩放比例至200%) 1 进入GitHub官网:http ...

  5. css3的calc()

    计算大小宽度距离的一个计算函数    使用方法  再括号中进行加减乘除的运算   例如: width : calc(100% - 75px) 注意  :符号左右两边要有空格

  6. 数据结构作业——图的存储及遍历(邻接矩阵、邻接表+DFS递归、非递归+BFS)

    邻接矩阵存图 /* * @Author: WZY * @School: HPU * @Date: 2018-11-02 18:35:27 * @Last Modified by: WZY * @Las ...

  7. [Codeforces Round #492 (Div. 1) ][B. Suit and Tie]

    http://codeforces.com/problemset/problem/995/B 题目大意:给一个长度为2*n的序列,分别有2个1,2,3,...n,相邻的位置可以进行交换,求使所有相同的 ...

  8. hdu4990 Reading comprehension 矩阵快速幂

    Read the program below carefully then answer the question.#pragma comment(linker, "/STACK:10240 ...

  9. day 04 Java并发多线程

    http://www.cnblogs.com/hellocsl/p/3969768.html?utm_source=tuicool&utm_medium=referralPS:而JVM 每遇到 ...

  10. mongodb备份与还原

    mongodb单机: 备份所有的库: mongodump --host 10.10.7.33:27019 --gzip --out /home/mongodb/0415_bf 备份指定的库: mong ...