2017-06-05 30 views
1

我試圖通過Python在Elasticsearch中創建一個索引。我有一個ES的本地實例部署和查詢運行良好。但是,我有一個模式。那就是:Elasticsearch fielddata索引映射時不受支持

{ 
    "mappings": { 
    "payment":{ 
     "properties":{ 
     "timestamp":{"type":"date"}, 
     "base_amount":{"type":"integer"}, 
     "derived_id":{"type":"keyword", "fielddata": true}, 
     "attempts":{"type":"integer"}, 
     "status":{"type":"text","fielddata":true}, 
     "error_code":{"type":"text","fielddata":true} 
     } 
    } 
    } 
} 

這裏是我使用的是創建這個索引

import json 

import requests 

schema = { 
    "mappings": { 
     "payment": { 
      "properties": { 
       "timestamp": {"type": "date"}, 
       "base_amount": {"type": "integer"}, 
       "derived_key": {"type": "keyword", "fielddata": True}, 
       "attempts": {"type": "integer"}, 
       "status": {"type": "text", "fielddata": True}, 
       "error_code": {"type": "text", "fielddata": True} 
      } 
     } 
    } 
} 

index = 'http://localhost:9200/payment_index_2016_08_21' 
r = requests.put(index, data=json.dumps(schema)) 

print r.content 
代碼

我得到的錯誤是

{ 「錯誤」:{ 「ROOT_CAUSE」: [{「type」:「mapper_parsing_exception」,「reason」:「Mapping [0124]解析 映射[payment]:[derived_key]的映射定義具有 不支持的參數:[fielddata: true]「,」causes_by「:{」type「:」mapper_parsing_exception「,」reason「:」映射 [derived_key]不支持的參數:[fielddata: 真] 「},」 狀態「:400}

我不明白爲什麼fielddata = true導致一個問題,因爲我看到它在這裏https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html允許的。任何線索背後的問題是什麼?

回答

1

您無需在關鍵字字段中啓用fielddata。您可以對關鍵字字段進行彙總。

+0

所以我只是刪除它,它應該工作正常? – bholagabbar

+0

是的。如果它不再提供錯誤:-) –

+0

是的,它的工作原理。所以你的意思是在關鍵字上,你可以默認執行聚合,並且我們不需要通過fielddata = true來啓用它(因爲它已經被啓用)並且fielddata的目的是執行聚合,對嗎? – bholagabbar

相關問題