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": "中国你好,我爱你中国"
}
相关推荐
旺仔Sec几秒前
2025年安徽省职业院校技能大赛(中职组)大数据应用与服务赛项样题
大数据
ctrigger1 小时前
中级统计师《统计基础理论及相关》考试大纲
大数据
SmartBrain2 小时前
洞察:阿里通义DeepResearch 技术
大数据·人工智能·语言模型·架构
不光头强4 小时前
git知识点总结
大数据·elasticsearch·搜索引擎
Elastic 中国社区官方博客4 小时前
Kibana:使用 ES|QL 构建地图,对国家或地区的指标进行对比
大数据·数据库·elasticsearch·搜索引擎·信息可视化·全文检索·kibana
fuzamei8885 小时前
AI+区块链:为数字金融构建可信交易底座—吴思进出席“中国数字金融独角兽榜单2025交流会”
大数据·人工智能
盟接之桥5 小时前
盟接之桥--说制造:从“找缝隙”到“一万米深”——庖丁解牛式的制造业精进之道
大数据·前端·数据库·人工智能·物联网·制造
司马阅-SmartRead5 小时前
学术研究与产业实践深度融合:司马阅AI合伙人冀文辉亮相「首届创新管理与JPIM论文工作坊」,产学研一体化推动企业AI落地
大数据·人工智能
kk哥88996 小时前
Git 远程仓库操作
大数据·git·elasticsearch
林义满7 小时前
大促零宕机背后的运维升级:长三角中小跨境电商的架构优化实践
大数据·运维·架构