Hi , I have a collection like
{
“_id”: 1,
“Code” : “X1_XXX2”,
“Category”: “12”
},
{
“_id”: 1,
“Code” : “X1_XXX3”,
“Category”: null
}
I have Code and Category indexed in Atlas Search as default index
Question is how can I search say for example :
Code :“X1” where Category is “12” or null
So far I tried :
db.getCollection("myCollection").aggregate([
{
$search: {
"compound":
{
"filter": [{
'$or': [ // error because i cannot use OR
{ Category: { '$eq': "000501" } },
{ Category: null },
]
}
],
"must": [{
"wildcard": {
query: "SE*",
path: "Code",
allowAnalyzedField: true
}
}]
}
}
},
{
$project: {
"_id": 1,
"Code": 1
}
}
])