2016-05-26 31 views
1

我有一些我想存儲爲字符串的birth_dates。我不打算對數據進行任何查詢或分析,我只是想存儲它。Elasticsearch 2.3放映射(試圖覆蓋日期字段類型)錯誤

我給出的輸入數據有很多不同的隨機格式,有些甚至包括像(approximate)這樣的字符串。 Elastic已經確定這應該是一個日期格式的日期字段,這意味着當彈性接收到像1981 (approx)這樣的日期時,它會嚇壞了,並說輸入格式無效。

而不是改變輸入日期我想改變日期類型爲字符串。

我已查看過文檔,並試圖用PUT映射API更新映射,但彈性一直返回解析錯誤。

根據記錄在這裏:

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html

我曾嘗試:

PUT /sanctions_lists/eu_financial_sanctions/_mapping 
{ 
    "mappings":{ 
     "eu_financial_sanctions":{ 
     "properties": { 
      "birth_date": { 
       "type": "string", "index":"not_analyzed" 
      } 
     } 
     } 
    } 
} 

但回報:

問題摘要

是否可以重寫elasticsearch的自動確定日期字段,強制字符串作爲字段類型?

注意

我使用谷歌Chrome插件感發送請求

彈性搜索的版本是2.3

回答

-1

剛剛從URL中移除型參考和匹配,你有他們的內部請求正文。 More examples.

PUT /sanctions_lists 
{ 
    "mappings":{ 
     "eu_financial_sanctions":{ 
     "properties": { 
      "birth_date": { 
       "type": "string", "index":"not_analyzed" 
      } 
     } 
     } 
    } 
} 
+0

我剛試過'PUT/sanctions_lists/_mapping'得到了另一個錯誤'「驗證失敗:1:映射類型缺失;」'如果我不包括「_mapping」不會就嘗試將其保存爲一個文件? –

+0

爲什麼你不能使用'PUT/sanctions_lists'?我已經在答案中加入了一些例子。 – pkhlop

+0

,因爲你的方法是添加一個新類型。我想更新現有的字段。我得到'「type」:「index_already_exists_exception」,' 然後使用鏈接的例子我試過了:'PUT/sanctions_lists/_mapping/eu_financial_sanctions'並得到錯誤''type「:」illegal_argument_exception「, 」reason「:」mapper不同類型的[birth_date],current_type [date],merged_type [string]「' –

相關問題