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"
}
相关推荐
1名持续学习的码农8 小时前
GPT Plus、GPT Pro用户第一次用Codex,项目权限和Git分支怎么设置?
人工智能·git·gpt·elasticsearch·ai编程·codex
小罗水10 小时前
附录A 各微服务完整 application.yml 配置汇总
数据库·elasticsearch·微服务
Elasticsearch12 小时前
使用 Gemma、Hugging Face 和 Elasticsearch 构建 RAG 系统
elasticsearch
Elasticsearch13 小时前
使用 NVIDIA NeMo Retriever、Unstructured 和 Elasticsearch 处理非结构化数据
elasticsearch
Elasticsearch15 小时前
使用 OpenAI 服务通过 Inference API 实现语义搜索
elasticsearch
Elasticsearch1 天前
跳过编写告警规则:NGINX OTel 集成中内置 6 个现成的 ES|QL 模板
elasticsearch
Elasticsearch2 天前
缩小 AI 差距:下一代知识访问如何为政府解锁任务成果
elasticsearch
Elastic 中国社区官方博客2 天前
Elasticsearch:搜索教程 - 语义搜索(三)
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
西邮彭于晏2 天前
图文详解:Git分支创建、合并与冲突解决|新手零门槛完整教程
大数据·git·elasticsearch