ES kibana 创建索引快速脚本

删除

复制代码
DELETE my_test

创建索引

创建自定义ngram分词器

复制代码
PUT my_test 
{
  "settings": {
    "index.max_ngram_diff": "32",
    "analysis": {
			"analyzer": {
				"code_analyzer": {
					"tokenizer": "code_tokenizer",
					"filter": [
                    	"lowercase"
                    ]
				}
			},
			"tokenizer": {
				"code_tokenizer": {
					"token_chars": [
						"letter",
						"digit"
					],
					"min_gram": "3",
					"type": "ngram",
					"max_gram": "32"
				}
			}
		}
  } 
}

设置字段

复制代码
PUT my_test/_mapping
{
  "properties": {
    "name":{
      "type":"text",
      "analyzer":"code_analyzer"
    }
  }
}

上传测试文档

复制代码
PUT my_test/_doc/1
{
  "name":"测试搜索09"
}

PUT my_test/_doc/2
{
  "name":"2009"
}

测试

复制代码
GET my_test/_search
{
  "query":{
    "match_phrase": {
      "name": "092"
    }
  }
}

测试分词

复制代码
GET my_test/_analyze
{
  "text": "测试搜索09",
  "tokenizer": "ngram"
}

GET core_product_basic/_analyze
{
  "text": "测试搜索09",
  "tokenizer": "ngram"
}
相关推荐
W|J22 分钟前
ES 学习笔记
笔记·学习·elasticsearch
CNRio1 小时前
Day 51:Git的高级技巧:使用Git的reflog恢复丢失的提交
大数据·git·elasticsearch
oMcLin2 小时前
如何在 Ubuntu 22.04 服务器上搭建并优化 Elasticsearch 集群,支持实时日志分析
服务器·ubuntu·elasticsearch
阿猿收手吧!2 小时前
【Elasticsearch】Elasticsearch:高性能分布式搜索与分析引擎
大数据·分布式·elasticsearch
Albert Edison20 小时前
【Git】分支管理
大数据·git·elasticsearch
愤怒的苹果ext21 小时前
Flink CDC MySQL同步到Elasticsearch
mysql·elasticsearch·flink·cdc·同步数据
CNRio1 天前
Day 43:Git的高级技巧:使用Git的rebase简化提交历史
大数据·git·elasticsearch
何中应1 天前
ES可视化连接工具的使用
大数据·elasticsearch·搜索引擎
Elastic 中国社区官方博客1 天前
Elasticsearch:在 Streams 中使用 ML 自动化 log 解析
大数据·运维·elk·elasticsearch·搜索引擎·自动化·全文检索
oMcLin1 天前
如何在Debian 11服务器上部署并优化高性能Elasticsearch集群,处理PB级数据?
服务器·elasticsearch·debian