Hi, we’re using Atlas Search in some sort of this way:
[
{
$search: {
index: "search_person",
compound: {
should: [
{
text: {
query: "robin",
path: "name",
},
},
{
text: {
query: "robin",
path: ["iban", "email"],
score: {
boost: {
value: 10,
},
},
},
},
],
},
sort: {
_score: {
$meta: "searchScore",
order: -1,
},
createdAt: 1,
_id: -1,
},
},
},
{
$addFields: {
_score: {
$meta: "searchScore",
},
},
},
]
But now we want to filter on searchScore
greater than 10.
Adding a $match
stage after the $search
inside the aggregation makes it (obviously) very slow:
{
$match: {
_score: {
$gte: 10
},
},
}
The documentation recommends to use filter
instead of $match
inside the compound
, but I think I don’t have searchScore
available at that point? Otherwise I could have tried with a range
.
Thank you in advance.
Kinds regards,
Robin van Wijngaarden