As pointed out in another question , nothing prevents you from storing the name Customer
inside each document order_item
during indexing, but it also has a dedicated index orders
, which also contains data Customer
. Remember that all this is connected with the mental denormalization of your data, so that each of your documents is "self-sufficient" as you need.
curl -XPUT localhost:9200/order_items/order_item/1 -d '{
"ID": 1,
"Name": "Shoes",
"Price": 9.99,
"OrderID": 82,
"Customer": "John Smith"
}'
curl -XPUT localhost:9200/order_items/order_item/2 -d '{
"ID": 2,
"Name": "Hat",
"Price": 19.99,
"OrderID": 82,
"Customer": "John Smith"
}
, , / OrderID
, .
, @JohnAment , order/order_item
order
...
curl -XPUT localhost:9200/orders/order/82 -d '{
"ID": 82,
"Customer": "John Smith"
}'
order_item
"children", , :
curl -XPUT localhost:9200/order_items/order_item/1?parent=82 -d '{
"ID": 1,
"Name": "Shoes",
"Price": 9.99
}'
curl -XPUT localhost:9200/order_items/order_item/2?parent=82 -d '{
"ID": 2,
"Name": "Hat",
"Price": 19.99
}'
order
OrderItems
:
curl -XPUT localhost:9200/orders/order/82 -d '{
"ID": 82,
"Customer": "John Smith"
"OrderItems": [
{
"ID": 1,
"Name": "Shoes",
"Price": 9.99
},{
"ID": 2,
"Name": "Hat",
"Price": 19.99
}
]
}'