- You can use
$indexOfCPto check if the search URL starts with the baseconfigurationURL by checking if the result is 0. ie. the configuration URL is found at index=0 of the search URL. - Combine that with a
$mapand$anyElementTrueto get an array of True/False for when that starting index is 0.
db.collection.find({
$expr: {
$anyElementTrue: [
{
$map: {
input: "$configuration.urls",
in: {
$eq: [
{
// your search url
$indexOfCP: ["https://example.com/some_path", "$$this", 0]
},
0
]
}
}
}
]
}
})
This can also be done as a $filter with the same indexOfCP operation and then checking if the array is non-empty. (But requires an additional equality check anyway.)