es自定义分词器支持数字字母分词,中文分词器jieba支持添加禁用词和扩展词典

自定义分析器,分词器

json 复制代码
PUT http://xxx.xxx.xxx.xxx:9200/test_index/
{
  "settings": {
    "analysis": {
      "analyzer": {
        "char_test_analyzer": {
          "tokenizer": "char_test_tokenizer",
          "filter": [
            "lowercase"
          ]
        }
      },
      "tokenizer": {
        "char_test_tokenizer": {
          "type": "ngram",
          "min_gram": 1,
          "max_gram": 2
        }
      }
    }
  },
  "mappings": {
    "test_zysf_index": {
      "properties": {
        "text": {
          "type": "text",
          "analyzer": "char_test_analyzer"
        }
      }
    }
  }
}

所有字段检索

json 复制代码
{
	"query": {
		"multi_match": {
			"query": "河北保定",
			"type": "cross_fields",
			"fields": ["*"],
			"operator": "AND"
    }
	}
}

高亮搜索

json 复制代码
{
  "highlight": {
    "fields": {
        "name": {},
        "content": {},
    },
    "pre_tags": ["<em>"],
    "post_tags": ["</em>"]
  }
}

分词测试

GET /test_index/_analyze

json 复制代码
{
  "analyzer": "char_test_analyzer",
  "text": "adfsjdsa12345646abADS"
}

jieba中文分词支持添加禁用词和扩展词库功能

创建索引:PUT http://xxxx:9200/test_index

json 复制代码
{
	"settings": {
		"analysis": {
			"filter": {
				"jieba_stopword": {
					"type": "stop",
					"stopwords_path": "/home/stopwords.txt"
				}
			},
			"tokenizer": {
	        	"jieba_tokenizer": {
		          	"type": "jieba_index",
		          	"user_dict": "/home/user.dict"
        		}
      		},
			"analyzer": {
				"my_jieba": {
					"filter": [
						"lowercase",
						"jieba_stopword"
					],
					"tokenizer": "jieba_tokenizer"
				}
			}
		}
	},
	"mappings": {
    	"test_index": {
      		"properties": {
        		"name": {
          			"type": "text",
					"index": true,
					"analyzer": "my_jieba",
					"similarity": "BM25"
        		}
      		}
    	}
  	}
}

分词测试:

GET http://xxxxxx:9200/test_index/_analyze

json 复制代码
{
  "analyzer": "my_jieba",
  "text": "中国你好,我爱你中国"
}
相关推荐
媒介发稿小能手8 小时前
权威+垂直+全域媒体资源:选对GEO发稿平台,抢占AI搜索高地
大数据·人工智能·媒体
滴图客户服务经理9 小时前
出行APP里的“预计到达时间“是怎么算出来的?
大数据·经验分享·百度
听你说329 小时前
原创专利+渠道生态,燃刻领跑电竞房定制赛道
大数据·人工智能·智能家居
腾讯云大数据1 天前
腾讯云大数据计算智能:从结构化 SQL 到多模态 AI Workload 的融合范式
大数据·人工智能·腾讯云
AI职业加油站1 天前
大数据采集工程师:技术栈全景图与实战路径
大数据·人工智能·数据分析
阿里云大数据AI技术1 天前
AI Search × ES Agent Builder 最佳实践:企业智能助手落地指南
人工智能·elasticsearch
老白讲技术1 天前
2026年国内APP开发与软件定制服务商能力观察:从AI应用到行业系统开发
大数据·人工智能·ai·app·软件需求·app开发
荣-1 天前
从两天到十几分钟:一套 YT Crash 自动化分析工具完整工程复盘
大数据·运维·自动化
人工智能培训1 天前
大模型驱动下传统大数据架构的变革方向
大数据·人工智能·重构·架构·agent·agi
蜡笔削薪1 天前
财联万业(杭州)数字科技有限公司能否给代理划定独家经营区域?
大数据·人工智能·python·科技