总结
1、能中文分词,安装ik插件,阿里云es默认就带有
2、获取词频
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html#docs-termvectors
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html
安装分词插件
1.需要中文分析。中文分词器有多种,ik为默认且较好,aliws(AliNLP分词)分的太细
2.需要分词更准确。导入关键词,扩展词典(词库),导入后需要重新索引文档
#测试分词效果
GET _analyze
{
"analyzer": "ik_smart",
"text": ["医生胃炎阴虚体寒的人能吃吗"]
}
https://help.aliyun.com/document_detail/137928.html?spm=a2c4g.11186623.6.638.1a8dfc44Q6OP3J
词典(词库)扩展
实践了es管理的的热更新,需要手动上传dic文件,首次文件会被要求重启服务,启动大约几分钟,所以需要晚上停止服务处理。
IK自带的主词库
SYSTEM_MAIN.dic
停用词主词库
SYSTEM_STOPWORD.dic
停用词是指在信息检索中,为节省存储空间和提高搜索效率,在处理自然语言数据(或文本)之前或之后会自动过滤掉某些字或词,这些字或词即被称为Stop Words(停用词)。这些停用词都是人工输入、非自动化生成的,生成后的停用词会形成一个停用词表。但是,并没有一个明确的停用词表能够适用于所有的工具。
存储(索引)能查词频的文档
1.定义文档的mapping(text,分词器)
PUT /ga_comment
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"reply_comment_id": {
"type": "keyword"
},
"platform_code": {
"type": "keyword"
},
"account_id": {
"type": "keyword"
},
"es_id": {
"type": "keyword"
},
"open_id": {
"type": "keyword"
},
"open_video_id": {
"type": "keyword"
},
"open_comment_id": {
"type": "keyword"
},
"account_name": {
"type": "text",
"analyzer" : "ik_smart"
},
"video_title": {
"type": "text",
"analyzer" : "ik_smart"
},
"content": {
"type": "text",
"term_vector": "yes",
"store" : true,
"analyzer" : "ik_smart"
},
"comment_time": {
"type": "date"
},
"pull_time": {
"type": "date"
},
"delete_time": {
"type": "date"
},
"create_time": {
"type"