[英]Elasticsearch - Include fields in highlight excluded in _source
I know objects marked as excluded in the _source mapping can be included in the search query. 我知道_source映射中标记为排除的对象可以包含在搜索查询中。 But I have a requirement to include matching terms in the highlight section of the response.
但是我要求在响应的突出显示部分中包含匹配的术语。
eg I have a mapping like: 例如我有一个像这样的映射:
{
"mappings": {
"doc": {
"_source": {
"excludes": ["some_nested_object.complex_tags_object"]
},
"properties": {
"some_nested_object": {
"type": "nested"
}
}
}
}
}
Search Query: 搜索查询:
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": {}
}
}
}
If I don't exclude in the mapping but in the search query at runtime then I am able to return matching terms in the highlight section but the response is very slow due to the large size of the object. 如果我不在运行时在映射中而是在搜索查询中排除,则可以在突出显示部分中返回匹配的术语,但是由于对象较大,因此响应速度很慢。
So is it possible to include fields marked as exclude
in the mapping/doc/_source as part of highlight ? 那么是否有可能在mapting / doc / _source中包含标记为
exclude
字段作为突出显示的一部分?
So is it possible to include fields marked as exclude in the mapping/doc/_source as part of highlight?
因此,是否可以在mapping / doc / _source中包含标记为排除的字段作为突出显示的一部分?
The short answer to your question unfortunately is no . 不幸的是,对您的问题的简短回答是“ 否” 。 From the Elasticsearch highlighting documentation :
从Elasticsearch 突出显示的文档中 :
Highlighting requires the actual content of a field.
突出显示需要字段的实际内容。 If the field is not stored (the mapping does not set
store
totrue
), the actual_source
is loaded and the relevant field is extracted from_source
.如果未存储该字段(映射未将
store
设置为true
),则会加载实际的_source
,并从_source
提取相关的字段。
You have a few options, each of which involve compromise: 您有几个选择,每个选择都涉及折衷:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.