[英]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.