[英]Elasticsearch - Include fields in highlight excluded in _source
我知道_source映射中标记为排除的对象可以包含在搜索查询中。 但是我要求在响应的突出显示部分中包含匹配的术语。
例如我有一个像这样的映射:
{
"mappings": {
"doc": {
"_source": {
"excludes": ["some_nested_object.complex_tags_object"]
},
"properties": {
"some_nested_object": {
"type": "nested"
}
}
}
}
}
搜索查询:
GET my_index/_search {
"size": 500,
"query": {
"bool": {
"must": [{
"nested": {
"query": {
"bool": {
"must":
[{
"match_phrase_prefix": {
"some_nested_object.complex_tags_object.name": {
"query": "account"
}
}
}
]
}
},
"path": "some_nested_object"
}
}
]
}
},
"highlight": {
"pre_tags": [
""
],
"post_tags": [
""
],
"fields": {
"some_nested_object.complex_tags_object.name": {}
}
}
}
如果我不在运行时在映射中而是在搜索查询中排除,则可以在突出显示部分中返回匹配的术语,但是由于对象较大,因此响应速度很慢。
那么是否有可能在mapting / doc / _source中包含标记为exclude
字段作为突出显示的一部分?
因此,是否可以在mapping / doc / _source中包含标记为排除的字段作为突出显示的一部分?
不幸的是,对您的问题的简短回答是“ 否” 。 从Elasticsearch 突出显示的文档中 :
突出显示需要字段的实际内容。 如果未存储该字段(映射未将
store
设置为true
),则会加载实际的_source
,并从_source
提取相关的字段。
您有几个选择,每个选择都涉及折衷:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.