const totalcount = await model.aggregate([
{
$search: {
index: 'keywordsearch',
text: {
path: 'Keywords',
query: req.query.searchdes,
fuzzy: {
maxEdits: 2,
maxExpansions: 20,
},
},
},
},
{
$count: 'total_count',
},
])
This query running very slow and takes almost 1-2 minutes when ran over a collection of 2 Million data. Keywords field is a comma seperated string values in database.
Is there any way to optimize this query to get faster count results?