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": "中国你好,我爱你中国"
}
相关推荐
yaoyouzhong38 分钟前
MySQL 批量插入详解:快速提升大数据导入效率的实战方法
大数据·数据库·mysql
云栖梦泽2 小时前
AI安全合规与治理:行业发展趋势与职业展望
大数据·人工智能·安全
得物技术2 小时前
财务数仓 Claude AI Coding 应用实战|得物技术
大数据·llm·aiops
rainy雨4 小时前
免费且好用的精益工具在哪里?2026年精益工具清单整理
大数据·人工智能·信息可视化·数据挖掘·数据分析·精益工程
蚂蚁数据AntData4 小时前
破解AI“机器味“困境:HeartBench评测实践详解
大数据·人工智能·算法·机器学习·语言模型·开源
Jane - UTS 数据传输系统4 小时前
立足国家“十五五”数智化战略大局,紧扣上海“2+3+6+6”产业布局,UTS数据传输系统筑牢数智化转型数据底座
大数据·人工智能·跨平台·信创·跨数据库·十五五·国产数据库适配
xcbrand4 小时前
口碑好的品牌策划厂家
大数据·人工智能·python
Elasticsearch6 小时前
Elasticsearch:运用 JINA 来实现多模态搜索的 RAG
elasticsearch
wzl202612137 小时前
企微私域工具免费版vs付费版:数据统计API差异与自动化报表脚本实现
大数据·自动化·企业微信
key_3_feng8 小时前
MCP协议:解锁AI模型与外部世界的高效协作
大数据·人工智能·mcp