I need to query and get the data from database with the condition, if weight is equal to 20 in the above nested object and i have to get the Banana and orange object as a result. Could you please help me out.
It looks like you have one document with all your data in it. That’s not a database. In a database each separate item has its own document. So you’d have a document named “Apple” with properties “color” and “weight”, etc. (And it’s better to make “weight” a number, not a string. Otherwise comparisons won’t work right.)
Once you do that you can query the documents using the query you already wrote. The reason the query doesn’t work now is that there is no property named “weight” in the document — instead you’ve got nested properties like “Apple.weight”, “Orange.weight” etc.