如何使用快速矢量荧光笔正确设置大文档中的突出显示搜索词?
我尝试过文档和索引的以下设置(作为Python文字,注释了替代设置,我也尝试过,包括存储和不存储):
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"members": {
"dynamic": "strict",
"properties": {
"url": {
"type": "text",
"term_vector": "with_positions_offsets",
#"index_options": "offsets",
"store": True
},
"title": {
"type": "text",
#"index_options": "offsets",
"term_vector": "with_positions_offsets",
"store": True
},
"content": {
"type": "text",
#"index_options": "offsets",
"term_vector": "with_positions_offsets",
"store": True
}
}
}
}
}通过以下查询完成的搜索(同样,在某些组合中,一个接一个地尝试了注释位置):
{
"query": {
"multi_match": {
"query": term,
"fields": ["url", "title", "content"]
},
},
"_source": {
#"includes": ["url", "title", "_id"],
# "excludes": ["content"]
},
"highlight": {
"number_of_fragments": 40,
"fragment_size": 80,
"fields": {
"content": {"matched_fields": ["content"]},
#"content": {"type": "fvh", "matched_fields": ["content"]},
#"title": {"type": "fvh", "matched_fields": ["title"]},
}
}
}问题是,当不使用FVH时,ElasticSearch抱怨"content“字段太大。(我不想增加允许的大小)。当我添加"fvh“类型时,ES抱怨术语向量是必需的:尽管我已经通过查询文档信息(偏移、启动等)检查了它们:
字段内容应该用术语向量索引,并带有位置偏移,与快速矢量荧光笔一起使用。
似乎:
当我省略"with_positions_offsets".
它也非常危险,只有当遇到一个大型文档时,它才会失败。在文档较小的情况下,查询中会出现突出显示。
在ElasticSearch 7免费版中设置突出显示的正确方法是什么(我在Ubuntu下尝试了来自供应商的二进制deb )?
发布于 2020-11-05 05:50:47
fvh荧光笔使用Lucene快速矢量荧光笔。此荧光笔可用于映射中将term_vector设置为with_positions_offsets的字段。快速矢量高亮器需要将term_vector设置为with_positions_offsets,这将增加索引的大小。
您可以为您的字段定义如下所示的映射。
"mappings": {
"properties": {
"text": {
"type": "text",
"term_vector": "with_positions_offsets"
}
}
}在查询突出显示字段时,需要使用"type" : "fvh"
由于启用了术语向量,因此在默认情况下,将对文本字段使用快速矢量荧光笔。
https://stackoverflow.com/questions/61045439
复制相似问题