将Word文档读取存入ES来方便查找某个关键词在那个文档,为了不使ES的数据过于庞大打算只储存分词后的索引而不存储原始数据。本来这是一个很简单的操作,可是搜索出来的好像不太对要不就是老版本的7.x版本的ES已经不支持这个字段了而难住了,但是功夫不负有心人在一顿瞎操作下成功了。
(⊙﹏⊙)主要是那个能使用的方案没有给出全部Json导致我错误理解了,为了方便下次使用特意水此一贴
PUT _template/word_index
{
"index_patterns": [
"word_index_*"
],
"settings": {
"number_of_replicas" : 3,
"number_of_shards" : 5
},
"mappings": {
"_source": {
"excludes": ["contents"]
},
"properties": {
"contents": {
"index": true,
"analyzer": "ik_max_word",
"term_vector": "with_positions_offsets",
"type": "text",
"store": false
},
"no": {
"type": "keyword"
},
"file_name": {
"type": "keyword"
},
"file_path": {
"type": "keyword"
}
}
}
}
contents字段是Word文档的内容,使用excludes忽略不记录。
ChiuYut
2021年4月1日