Return the amount of results in a Search query
I don't think there's currently a way to see this today? Seems like a missing basic feature.
1
vote
Tim Frietas
shared this idea
-
Justin commented
Its an aggregate pipeline so you can just add a $count pipeline step after the query. If you want the results and the count in the same query then use a facet and a $count like so:
```
db.example.aggregate([
{ $searchBeta: { ... } },
{
$facet: {
results: [{ $project: { ... } }],
total: [{ $count: "total" }]
}
}
])
```