POST /sample_order/_bulk
{"index":{"_id":1}}
{"orderNo":"1","orderLines":[{"item":{"itemDesc":"SampleItemDesc1","itemID":11}}]}
{"index":{"_id":2}}
{"orderNo":"2","orderLines":[{"item":{"itemDesc":"SampleItemDesc2","itemID":22}}]}
Now if we want to run following query:
{
"query": "SELECT * FROM sample_order where orderLines.item.itemID=11",
"fetch_size": 10
}
It doesn't return any records.
If we change it to:
{
"query": "SELECT * FROM sample_order where nested(orderLines.item.itemID)=11",
"fetch_size": 10
}
It throws error mentioning:
nested object under path [orderLines.item] is not of nested type
How can we query objects inside nested structures?
Could you please assist in this Experts. We really appreciate your help!
Hello Experts,
Our Index Mapping has several nested structures and objects within it. Just to showcase the issue, please consider the following sample mapping
PUT /sample_order { "mappings": { "properties": { "orderNo":{ "type": "text" }, "orderLines": { "type": "nested", "properties": { "item": { "type": "object", "properties": { "itemDesc": { "type": "text" },"itemID": { "type": "integer" } } } } } } } }
POST /sample_order/_bulk {"index":{"_id":1}} {"orderNo":"1","orderLines":[{"item":{"itemDesc":"SampleItemDesc1","itemID":11}}]} {"index":{"_id":2}} {"orderNo":"2","orderLines":[{"item":{"itemDesc":"SampleItemDesc2","itemID":22}}]}
Now if we want to run following query: { "query": "SELECT * FROM sample_order where orderLines.item.itemID=11", "fetch_size": 10 } It doesn't return any records.
If we change it to: { "query": "SELECT * FROM sample_order where nested(orderLines.item.itemID)=11", "fetch_size": 10 } It throws error mentioning: nested object under path [orderLines.item] is not of nested type
How can we query objects inside nested structures? Could you please assist in this Experts. We really appreciate your help!
Thanks!