I have Order details and Order Items as nested documents. This means one order will have multiple order item details.
Let's say the item details has item name and when user searches for a particular item, I need to display order number, order amount, item name (only matching - not all).
How do I achieve this. When I do a nested query, the whole document along with other items details is fetched, but I cannot display other items which were not searched..
I am currently using Elasticsearch 2.3.4 version.
Sample data
{
"Order Id" : 123456,
"Order Amount" : 20000,
"Item Details" : [
{ "Item Name" : "Pencil", "Quantity" : 100 },
{ "Item Name" : "Pen", "Quantity" : 150 },
{ "Item Name" : "Books", "Quantity" : 300 }
]
}
Output : When searched for Books
{
"Order Id" : 123456,
"Order Amount" : 20000,
"Item Details" : [
{ "Item Name" : "Books", "Quantity" : 300 }
]
}