Given a list of documents like:
[
{
_id: 1,
field: {
subfield1: [
"value", "test"
],
subfield2: [
"value"]
},
paths: [
"field.subfield1",
"field.subfield2"
]
},
{
_id: 2,
field: {
subfield1: [
"value"
],
subfield2: [
"test"
]
},
paths: [
"field.subfield2"
]
},
{
_id: 3,
field: {
subfield1: [
"test"
],
subfield2: [
"value"
]
},
paths: [
"field.subfield2"
]
},
{
_id: 4,
field: {
subfield1: [
"value"
],
subfield2: [
"value", "test"
]
},
paths: [
"field.subfield1"
]
}
]
in which paths
field is an array with paths to document. I have to return documents that have test
as a value in at least one of the paths specified in the paths
array. For example, the documents with _id
1 and _id
2 would be returned, because at least one of the values in paths
is a path in the document with value test
. Documents with _id
3 and _id
4 are not returned since no element of paths
is a path in the document that has value test
. The real case is bit more complicated, because there is one more level in field object, so, field
would be something like:
field: {
subfield1: {
subsubfield1: ["value", "test"]
}
}
and paths
values would be something like field.subfield1.subsubfield1
.