Hi,
i want to parse a json response and load data into elasticsearch via logstash ,
i try to delete arrDate and depDate fields if it's empty ,,,but i still got this error,
[2020-10-01T13:24:13,646][WARN ][logstash.outputs.elasticsearch][main][8dafa128c9ab419583f2bd9f8b39512559e9b500bbfe515cd29596f761e77443] Could not index event to Elasticsearch. {:status=>400, :action=>["update", {:_id=>"63198", :_index=>"invoices", :routing=>nil, :_type=>"_doc", :retry_on_conflict=>1}, #LogStash::Event:0x3a09cff0], :response=>{"update"=>{"_index"=>"invoices", "_type"=>"_doc", "_id"=>"63198", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse field [bookings.arrDate] of type [date] in document with id '63198'. Preview of field's value: ''", "caused_by"=>{"type"=>"illegal_argument_exception", "reason"=>"cannot parse empty date"}}}}}
my filter :
filter {
split { field => "[invoices]" }
mutate {
rename => {
"[invoices][invoiceRef]" => "invoiceRef"
"[invoices][invoiceId]" => "invoiceId"
"[invoices][invoiceType]" => "invoiceType"
"[invoices][invoiceStatus]" => "invoiceStatus"
"[invoices][invoiceDate]" => "invoiceDate"
"[invoices][amount]" => "amount"
"[invoices][currency]" => "currency"
"[invoices][billingTo]" => "billingTo"
"[invoices][customerId]" => "customerId"
"[invoices][customer]" => "customer"
"[invoices][distributorId]" => "distributorId"
"[invoices][distributor]" => "distributor"
"[invoices][bookings]" => "bookings"
}
}
if [bookings.arrDate] == "" {
mutate {
remove_field => ["bookings.arrDate"]
}
}
}
my data:
{
"invoices": [
{
"invoiceRef": "2020/B/000186",
"invoiceId": 63625,
"invoiceType": "Facture",
"invoiceStatus": "validée",
"invoiceDate": "2020-06-30",
"amount": 143.960,
"currency": "TND",
"billingTo": "Didi Travel",
"customerId": "",
"customer": "",
"distributorId": 13666,
"distributor": "DIDI TRAVEL",
"bookings": [
{
"bookingRef": 559986,
"bookingId": 559986,
"arrDate": "2020-06-27",
"depDate": "2020-06-28",
"detail": "Club Marmara Palm Beach Hammamet 4*
Tunisie,Hammamet
chambre double VP Standard Vue piscine - Soft All Inclusive
2 pax : 2 adultes
27 juin 2020 - 28 juin 2020 (1 nuit)
Amine Ben Ouali"
}
]
}]}
any hel please !