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"
}
相关推荐
ALex_zry9 小时前
Git大型仓库推送失败问题完整解决方案
大数据·git·elasticsearch
二进制coder10 小时前
Git Fork 开发全流程教程
大数据·git·elasticsearch
Elasticsearch19 小时前
混合搜索无需头疼:使用 retrievers 简化混合搜索
elasticsearch
Elastic 中国社区官方博客19 小时前
使用 A2A 协议和 MCP 在 Elasticsearch 中创建一个 LLM agent 新闻室:第二部分
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
q***65692 天前
使用Canal将MySQL数据同步到ES(Linux)
linux·mysql·elasticsearch
周全全2 天前
基于ElasticSearch的语义检索学习-向量化数据、向量化相似度、向量化检索
大数据·学习·elasticsearch
TH_12 天前
腾讯云-(10)-宝塔面板-Docker下安装Elasticsearch
elasticsearch·docker·容器
risc1234562 天前
【Elasticsearch】AwarenessAllocationDecider 感知分片决策器的处理逻辑
elasticsearch
transitory_truth2 天前
es-api介绍
elasticsearch
q***47183 天前
使用Canal将MySQL数据同步到ES(Linux)
linux·mysql·elasticsearch