2015-08-13 38 views
1

我的映射:如何在Elasticsearch中突出顯示日期字段?

"mappings": { 
    "my_type": { 
     "properties": { 
      "birthDate": { 
       "type": "date", 
       "format": "dateOptionalTime" 
      }, 
      "name": { 
       "type": "string" 
      } 
     } 
    } 
} 

我的搜索查詢:

GET my_index/_search 
{ 
    "query": { 
    "bool": { 
     "should": [ 
     { 
      "match": { 
      "name": "babken" 
      } 
     }, 
     { 
      "term": { 
      "birthDate": { 
       "value": "1999-01-01" 
      } 
      } 
     } 
     ] 
    } 
    }, 
    "highlight": { 
    "fields": { 
     "*": {} 
    } 
    } 
} 

但是在響應體中,只有name字段高亮顯示,即使birthDate領域已經匹配,以及:

"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>" 
       ] 
      } 
     } 
     ... 

如何使「birthDate」字段顯示在「突出顯示」結果中,以及它是否匹配?

我使用Elasticsearch 1.6

回答

1

您需要更改類型string,使突出。

要啓用突出顯示的字段的最低要求是它應該是string類型。

以下issue有關於它的更多討論。

+0

這沒有幫助嗎? – keety

相關問題