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"
}
相关推荐
在未来等你3 小时前
Elasticsearch面试精讲 Day 15:索引别名与零停机更新
大数据·分布式·elasticsearch·搜索引擎·面试
在未来等你4 小时前
Elasticsearch面试精讲 Day 12:数据建模与字段类型选择
大数据·分布式·elasticsearch·搜索引擎·面试
在未来等你8 小时前
Elasticsearch面试精讲 Day 14:数据写入与刷新机制
大数据·分布式·elasticsearch·搜索引擎·面试
phac1238 小时前
git 如何直接拉去远程仓库的内容且忽略本地与远端不一致的commit
大数据·git·elasticsearch
在未来等你8 小时前
Elasticsearch面试精讲 Day 11:索引模板与动态映射
大数据·分布式·elasticsearch·搜索引擎·面试
哥哥还在IT中9 小时前
Elasticsearch优化从入门到精通
大数据·elasticsearch·搜索引擎
Elastic 中国社区官方博客9 小时前
使用 cloud-native Elasticsearch 与 ECK 运行
大数据·数据库·elasticsearch·搜索引擎·kubernetes·k8s·全文检索
2301_7816686120 小时前
Elasticsearch 02
大数据·elasticsearch·搜索引擎
赵孝正1 天前
GitLab 分支管理与 Push 问题全解析
大数据·elasticsearch·gitlab
一刀到底2111 天前
springboot3.3.5 集成elasticsearch8.12.2 ssl 通过 SSL bundle name 来实现
网络·elasticsearch·ssl·springboot3