MarkLogic version : 9.0-6.2
I have an array in a json document as follows. My need is to return this document only if the email is "[email protected]" and EmailOverrideInd is "N" for that particular email.
"Contacts": [
{
"FirstName": "FTest1",
"LastName": "LTest1",
"Email": "[email protected]",
"EmailOverrideInd": "Y"
},
{
"FirstName": "Ftest2",
"LastName": "Ltest2",
"Email": "[email protected]",
"EmailOverrideInd": "N"
}
]
In the example given above, the query should not return the document as the EmailOverrideInd is "N" for email [email protected]
With the regular cts.jsonPropertyValueQuery and the cts.andQuery, I am still getting the document because my search is not limiting the scope to each array occurrence.
cts.search(
cts.andQuery(
[
cts.collectionQuery('testcol'),
cts.jsonPropertyValueQuery('Email', EmailAddr, ['exact']),
cts.jsonPropertyValueQuery('EmailOverrideInd', 'N', ['exact'])
]
),
['unfiltered','score-zero']
)
How can I limit my search to each array occurrence?
Contacts: [{ Contact: { FirstName: ...,... } }, { Contact: ... } ]
. It would greatly simplify your query, as it would allow using jsonPropertyScopeQuery on Contact.. – grtjn