I need more accurate search index results

Hello, I have the following query while using the search index:

await Collection.aggregate([
            {
                "$search": {
                    "index": "search",
                    compound: {
                        should: [
                            {
                                autocomplete: {
                                    query: `${req.query.query}`,
                                    path: 'name',
                                    "fuzzy": {
                                        "maxEdits": 2,
                                        "prefixLength": 3
                                    }
                                },
                            },
                            {
                                autocomplete: {
                                    query: `${req.query.query}`,
                                    path: 'contract',
                                    "fuzzy": {
                                        "maxEdits": 2,
                                        "prefixLength": 3
                                    }
                                },
                            },
                        ],
                    },
                },
            },
            {
                $limit: 15
            }
        ])

The problem is that the results are not very accurate, for example:

What I wrote is almost exactly the collection name of “BoredGoats” that is showing me as the second result.

What can I do to solve this problem? To have more accurate results.

Hey there, @foco_radiante – can you share your index definition?

One idea is to boost exact matches – there is an explanation of this here and example here.

{
  "mappings": {
    "dynamic": false,
    "fields": {
      "contract": [
        {
          "foldDiacritics": false,
          "maxGrams": 7,
          "minGrams": 3,
          "tokenization": "edgeGram",
          "type": "autocomplete"
        }
      ],
      "name": [
        {
          "foldDiacritics": false,
          "maxGrams": 7,
          "minGrams": 3,
          "tokenization": "edgeGram",
          "type": "autocomplete"
        }
      ]
    }
  }
}