My couchbase document looks like this:
{
“Apple”: {
“color” : “red”,
“weight”: “10”
},
“Orange”:{
“color”: “orange”,
“weight”: “20”
},
“Banana”: {
“color”: “yellow”,
“weight”: “20”
}
}
By using mutable document, i have saved the documents in database with above format.
I have tried like this:
Query query = QueryBuilder.
select(SelectResult.expression(Expression.all))
.from(DataSource.database(couchDbSample.database))
.where(Expression.property("weight").equalTo(Expression.string("20")));
query.addChangeListener(new QueryChangeListener() {
@Override
public void changed(QueryChange change) {
ResultSet resultRows = change.getResults();
......
}
}
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.