I want to do a $text $search on a mongoDB collection where the documents have a field that is an array of fields.
My query is returning false for some reason. Can't figure it out as I've already put an index on "conditions.description" in the collection.
Example Document in collection
{
"_id": "58f9c87b5246af0aac145ew",
"total": 2,
"patientId": "xxxxxxx",
"conditions": [
{
"verificationStatus": "confirmed",
"dateRecorded": "2017-03-14",
"clinicalStatus": "active",
"description": "Afib"
},
{
"verificationStatus": "confirmed",
"dateRecorded": "2017-03-14",
"clinicalStatus": "active",
"description": "Arterial hypertension"
}
]
}
My MongoDB Query that is returning false
.find({
"$and": [
{ "patientId": { $eq: pID } },
{ "conditions.description": { $text: { $search: "diabetes hypertension" }, $caseSensitive: false } }
]
})