索引 搜索 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. 使用matlab和ISE 创建并仿真ROM IP核

    前言 本人想使用简单的中值滤波进行verilog相关算法的硬件实现,由于HDL设计软件不能直接处理图像,大部分过程都是可以将图像按照一定的顺序保存到TXT文档中,经过Modelsim仿真后,处理的数据 ...

  2. Unity 3D用简单的Cube、Sphere实现镜面/哈哈镜效果,只需十几秒哦!

    Unity实现镜面和哈哈镜效果 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心分 ...

  3. nmon使用命令

    nmon使用命令   启动nmon后, c       查看CPU监控的窗口 mV     查看内存和虚拟内存            V是大写 ndt     查看网络.磁盘和虚拟进程 q      ...

  4. FZU软工第六次作业-团队选题报告

    作业链接 队长博客:陈晓彬 团队选题报告 选题报告PPT 原型展示 前言 经过团队的讨论,我们对自己的选题进行了项目立意的进一步确定,后面有项目来源.同时,我们将自己的APP的名字改成了"一 ...

  5. 聊聊 CAS

    哥有故事,你有酒,长夜漫漫,听我给你说. 参考资源: https://blog.csdn.net/hsuxu/article/details/9467651 1.概述 CAS,compare and ...

  6. ios-密码加密

    加密文件可到网上搜索MyMD5后下载 MyMD5.h文件 // // MyMD5.h // GoodLectures // // Created by yangshangqing on 11-10-1 ...

  7. React中jquery引用

    安装jQuery npm i jquery -S 在那个地方使用jQuery就在什么地方引入jQuery import $ from 'jquery'

  8. 一篇文章看懂java反射机制(反射实例化对象-反射获得构造方法,获得普通方法,获得字段属性)

    Class<?> cls = Class.forName("cn.mldn.demo.Person"); // 取得Class对象传入一个包名+类名的字符串就可以得到C ...

  9. oracle之logminer日志分析

    alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'; select sysdate from dual; 执行增删操作 alter sy ...

  10. .NET本质论 实例

    对象和值的比较 CLR的类型系统(其实就是通用类型系统(CTS),它定义了如何在运行库中声明,使用和管理类型,同时也是运行库支持跨语言集成的一个重要组成部分)将对应简单值的类型同对应传统"对 ...