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"
}
相关推荐
半夏知半秋17 小时前
Elasticsearch Query DSL 指令整理
大数据·数据库·笔记·学习·elasticsearch·搜索引擎·全文检索
半夏知半秋17 小时前
Elasticsearch专用的ES|QL语法指令整理
大数据·数据库·elasticsearch·搜索引擎·全文检索
Elasticsearch18 小时前
从数据到部署:推进美国州政府中 AI agent 的负责任使用
elasticsearch
Elasticsearch21 小时前
Streams 处理:告别 Grok 的困扰 - 在 Streams 中解析你的日志
elasticsearch
Elasticsearch21 小时前
Elasticsearch:使用判断列表评估搜索查询相关性
elasticsearch
武子康1 天前
大数据-181 Elasticsearch 段合并与磁盘目录拆解:Merge Policy、Force Merge、Shard 文件结构一文搞清
大数据·后端·elasticsearch
Elastic 中国社区官方博客1 天前
如何通过个性化、分群感知排序来提升电商搜索相关性
大数据·数据库·elasticsearch·搜索引擎·全文检索
Lisonseekpan1 天前
Elasticsearch 入门指南
大数据·分布式·后端·elasticsearch·搜索引擎
车斗1 天前
windows10 上安装 elasticsearch
开发语言·elasticsearch·全文检索
Lisonseekpan1 天前
技术选型分析:MySQL、Redis、MongoDB、ElasticSearch与大数据怎么选?
大数据·redis·后端·mysql·mongodb·elasticsearch