2015-11-07 56 views
1
DELETE /rosetta_account 

POST /rosetta_account/account_number 
{ 
     "settings" : { 
     "number_of_shards" : 20, 
     "number_of_replicas" : 2, 
     "index_analyzer" : "standard", 
     "search_analyzer" : "standard", 
     "date_detection" : false 
    } 
} 

curl -s -XPOST localhost:9200/rosetta_account/account_number/_bulk --data-binary @data.file 


{"took":68,"errors":true,"items":[{"create":{"_index":"rosetta_account","_type":"account_number","_id":"123456789","status":400,"error":"WriteFailureException; nested: MapperParsingException[failed to parse [customer_upgrade_dt]]; nested: MapperParsingException[failed to parse date field [], tried both date format [dateOptionalTime], and timestamp number with locale []]; nested: IllegalArgumentException[Invalid format: \"\"]; "}} 

回答

1

根據錯誤你:

failed to parse [customer_upgrade_dt] ... 
tried both date format [dateOptionalTime], and timestamp number with locale ... 
Invalid format: \"\" 

這意味着,包含在data.file您的JSON文件之一,你有一個字段名爲customer_upgrade_dt,其值是一個空字符串"",並且對於日期字段無效,如果該字段沒有任何值,則需要將其設置爲null或者根本不包含文檔中的字段。很明顯,日期仍在檢測中。

原因是因爲您在索引設置中將date_detection設置爲false,但這不是放置該參數的正確位置,您需要將其添加到映射中而不是索引設置中,即創建索引取而代之的是:

POST /rosetta_account/account_number 
{ 
    "settings" : { 
     "number_of_shards" : 20, 
     "number_of_replicas" : 2, 
     "index_analyzer" : "standard", 
     "search_analyzer" : "standard" 
    }, 
    "mappings": { 
     "account_number": { 
     "date_detection": false 
     } 
    } 
}