Inaccurate results for multiple search keywords in query atlas search autocomplete

I have made an autocomplete index in atlas search and searching for multiple keywords like “we are look”.
In this results I am getting shows documents that matches with ‘are’ keyword first and after that ‘we’ keyword documents.
I tried using tokenOrder but then I get no results.
Any idea what I can do to prioritize results on the basis of placement of keyword!

{
                $search: {
                  index: 'service_mv_index',
                  autocomplete: {
                    query: input.search,
                    path: 'name',
                    // tokenOrder: 'sequential'
                  },
              },
1 Like

Hi @Parab_Mishra , can you share a copy of your index definition and a few sample documents in the order that they are being returned? This will help when making a recommendation to achieve your desired behavior.

search query = “we are”
Results =

{
    "_id": "658e9eca189120f688e10e22",
    "salonName": "GREEN TRENDS AREKERE",
    "name": "GREEN TRENDS AREKERE",
    "distance": 91.67874921774914,
    "score": 5.674643516540527
  },
  {
    "_id": "65719918dc4ab88f27a7d80b",
    "salonName": "WELCODE UNISEX SALON",
    "name": "WELCODE UNISEX SALON",
    "distance": 91.56523351967104,
    "score": 4.746947288513184
  },

Here I placed we keyword first but getting the document matching with this keyword last. I want to prioritize keyword placement in the results.

Index Definition:

{
  "mappings": {
    "dynamic": true,
    "fields": {
      "name": {
        "minGrams": 1,
        "type": "autocomplete"
      }
    }
  }
}

Hey @Parab_Mishra , to boost specific terms I would recommend breaking down your query into separate clauses and specifying scoring parameters individually using the compound operator. E.g. the following query multiplies a document’s score by 3 if it matches on “we”. See this page for more options to modify score.

{
  $search: {
    index: 'service_mv_index',
    compound: {
      should: [
        {
            autocomplete: {
                path: "name",
                query: "we",
                score: { "boost": { "value": 3 } }
          },
         {
            autocomplete: {
                path: "name",
                query: "are",
          },
    },
},