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"
}
相关推荐
Elastic 中国社区官方博客6 小时前
使用 Elastic-Agent 或 Beats 将 Journald 中的 syslog 和 auth 日志导入 Elastic Stack
大数据·linux·服务器·elasticsearch·搜索引擎·信息可视化·debian
星星点点洲8 小时前
【RAG】RAG 系统的基本搭建流程(ES关键词检索示例)
python·elasticsearch
郝开1 天前
ElasticSearch 分词器介绍及测试:Standard(标准分词器)、English(英文分词器)、Chinese(中文分词器)、IK(IK 分词器)
elasticsearch·中文分词·ik·ik analyzer
kngines1 天前
【实战ES】实战 Elasticsearch:快速上手与深度实践-3.2.3 案例:新闻搜索引擎的相关性优化
大数据·elasticsearch·搜索引擎
天草二十六_简村人1 天前
JPA编程,去重查询ES索引中的字段,对已有数据的去重过滤,而非全部字典数据
java·大数据·spring boot·elasticsearch·搜索引擎·微服务·架构
C182981825751 天前
ES Filter Query 区别
elasticsearch
Elastic 中国社区官方博客1 天前
Elasticsearch:使用 BigQuery 提取数据
大数据·数据库·elasticsearch·搜索引擎·全文检索
小诸葛IT课堂1 天前
MySQL数据实时同步至Elasticsearch的高效方案:Java实现+源码解析,一文搞定!
java·mysql·elasticsearch
山上春2 天前
常见的 Git 命令
大数据·git·elasticsearch
kngines2 天前
【实战ES】实战 Elasticsearch:快速上手与深度实践-3.1.3高亮与排序的性能陷阱
大数据·elasticsearch·搜索引擎