中文分词增强 中文分词增强的优势 相比开源中文分词器,优化后的部分中文分词器在搜索结果上更具有优势。另外,天翼云云搜索服务中文分词增强模块内置了多种中文分词器,可以适应不同的场景,用户可以添加自定义词库来提高未登陆词的分词精度。 使用示例: 测试分词器分词效果: GET analyze { "text": "美国阿拉斯加州发生8.0级地震", "analyzer": "hanlp" } 返回结果: { "tokens": [{ "token": "美国", "startoffset": 0, "endoffset": 2, "type": "nsf", "position": 0 }, { "token": "阿拉斯加州", "startoffset": 2, "endoffset": 7, "type": "nsf", "position": 1 }, { "token": "发生", "startoffset": 7, "endoffset": 9, "type": "v", "position": 2 }, { "token": "8.0", "startoffset": 9, "endoffset": 12, "type": "m", "position": 3 }, { "token": "级", "startoffset": 12, "endoffset": 13, "type": "q", "position": 4 }, { "token": "地震", "startoffset": 13, "endoffset": 15, "type": "n", "position": 5 }] } 使用其他分词器可以在analyzer字段指定。 创建mappings的时候可以在字段中指定分词器: PUT demo { "mappings": { "properties": { "field1": { "type": "text", "analyzer": "hanlp" } } } } 返回结果: { "acknowledged": true, "shardsacknowledged": true, "index": "demo" }