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"
}
相关推荐
Elasticsearch39 分钟前
全领域的 AI 采用:主要用例和需避免的错误
elasticsearch
Elasticsearch1 小时前
使用 Maximum Marginal Relevance 实现搜索结果多样化
elasticsearch
oneslide6 小时前
elasticsearch备份恢复
大数据·elasticsearch·搜索引擎
张先shen16 小时前
Elasticsearch RESTful API入门:基础搜索与查询DSL
大数据·spring boot·elasticsearch·搜索引擎·全文检索·restful
厚道21 小时前
Elasticsearch 的存储原理
后端·elasticsearch
朴拙数科1 天前
在 macOS 上安装与自定义 Oh My Zsh:让终端美观又高效 [特殊字符]
大数据·elasticsearch·macos
张先shen1 天前
Elasticsearch深度分页解决方案:search_after原理剖析
大数据·elasticsearch·搜索引擎
Fireworkitte1 天前
ES 压缩包安装
大数据·elasticsearch
厚道2 天前
ES查询性能优化
elasticsearch
Fireworkitte3 天前
安装 Elasticsearch IK 分词器
大数据·elasticsearch