sql icon indicating copy to clipboard operation
sql copied to clipboard

Issues in querying nested objects

Open newUserForTesting opened this issue 4 years ago • 1 comments

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!

newUserForTesting avatar Aug 28 '21 03:08 newUserForTesting

Could someone please assist in the above query? Appreciate the help.

newUserForTesting avatar Sep 03 '21 16:09 newUserForTesting