I have a question on nested and parent/child objects.
Below are my sample nested documents –
DocumentID: 1
{
"UserID": 1,
"FirstName": "User1 First",
"LastNameName": "User1 Last",
"Assignments": [
{
"Role": "Role1",
"Permission": "P1",
"Value": "V1"
},
{
"Role": "Role2",
"Permission": "P2",
"Value": "V2"
}
]
}
DocumentID: 2
{
"UserID": 2,
"FirstName": "User2 First",
"LastNameName": "User2 Last",
"Assignments": [
{
"Role": "Role1",
"Permission": "P1",
"Value": "V1"
}
]
}
Below are my questions –
-
Is it mandatory to put “type:nested” for nested field “Assignments”? "Assignments' is an array which will have multiple sub-documents.
-
We mostly use queryString method for querying on these documents. Our queries generally are like below –
((Assignments.Role=Role1 AND Assignments.Role=Role2) OR (Assignments.Role=Role3 AND Assignments.Role=Role5) OR (Assignments.Role=Role3))
There can be multiple AND\OR conditions. We get expected results with above query. So do we have to add type:nested for nested field?
3. Also, if we use parent-child documents then can we add same child (same 'assignments' object in above case) to multiple parents?
I have gone through below link and it seems that there are few dis-advantages of adding type=nested property for nested field.
Request you to please provide your valuable suggestion.
Thanks,
Sameer