2 / 2
May 2024

I’m trying to normalize the score to apply a threshold using $match to improve the search abilities, but the steps $addField, $setWindowFields and $addField are taking too long, How can I improve this step?

First - help us understand why you need to normalize scores (generally that’s not done) - can you explain the scenario?

Also, can you provide the query aggregation pipeline? Note that stages that appear after $search will consume the full set of search results at that point - so do a $limit before those stages if possible, otherwise things will slow down the more results you have.