[英]How to highlight date fields in Elasticsearch?
My mapping: 我的映射:
"mappings": {
"my_type": {
"properties": {
"birthDate": {
"type": "date",
"format": "dateOptionalTime"
},
"name": {
"type": "string"
}
}
}
}
My search query: 我的搜索查询:
GET my_index/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"name": "babken"
}
},
{
"term": {
"birthDate": {
"value": "1999-01-01"
}
}
}
]
}
},
"highlight": {
"fields": {
"*": {}
}
}
}
However in the response body, only the name
field is highlighted, even though the birthDate
field has matched as well: 但是,在响应正文中,即使
birthDate
字段也已匹配,也仅突出显示了name
字段:
"hits": [
{
"_index": "my_index",
"_type": "my_type",
"_id": "1a82fbb4-1268-42b9-9999-ef932f67a114",
"_score": 12.507131,
"_source": {
"name": "babken",
"birthDate": "1999-01-01",
},
"highlight": {
"name": [
"<em>babken</em>"
]
}
}
...
How can I make the birthDate
field appear in "highlight" results as well if it has matched? 如果匹配,如何使
birthDate
字段也出现在“突出显示”结果中?
I'm using Elasticsearch 1.6 我正在使用Elasticsearch 1.6
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.