PUT /orders
{
"mappings": {
"properties": {
"lines": {
"type": "nested",
"properties": {
"amount": {
"type": "double"
},
"product_id": {
"type": "integer"
},
"quantity": {
"type": "integer"
}
}
},
"purchased_at": {
"type": "date"
},
"sales_channel": {
"type": "keyword"
},
"salesman": {
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "text"
}
}
},
"status": {
"type": "keyword"
},
"total_amount": {
"type": "double"
}
}
}
}
curl -XPUT "http://elasticsearch:9200/orders" -H 'Content-Type: application/json' -d'{ "mappings": { "properties": { "lines": { "type": "nested", "properties": { "amount": { "type": "double" }, "product_id": { "type": "integer" }, "quantity": { "type": "integer" } } }, "purchased_at": { "type": "date" }, "sales_channel": { "type": "keyword" }, "salesman": { "properties": { "id": { "type": "integer" }, "name": { "type": "text" } } }, "status": { "type": "keyword" }, "total_amount": { "type": "double" } } }}'
Bulk insert using curl
curl -s -XPOST localhost:9200/orders/_doc/_bulk -H "Content-Type: application/x-ndjson" --data-binary @orders-bulk.json