Atlas Search: autocomplete & highlight does not work

Hello there,

am I too dumb to read or does the highlight operator does not work with autocomplete?

Search Index:

    {
      "mappings": {
        "dynamic": true,
        "fields": {
              "hashTags": [
                {
                  "dynamic": true,
                  "type": "document"
                },
                {
                  "type": "string"
                },
                {
                  "tokenization": "nGram",
                  "type": "autocomplete"
                }
              ]
            },
            "type": "document"
          }
    }

Now, for a dataset like this:

    { 
    "uid": "xyz", 
    "hashTags": "abc, bca, kba"
    }

I wanted to use the following search stage:

    {
      index: 'abc',
      autocomplete: {
      path: 'hashTags',
      query: "smart",
      fuzzy: {}
    },
    "highlight": {
      "path": "hashTags",
      "maxCharsToExamine": 1000,
      "maxNumPassages": 5
     }
    }

and the $project stage:
    { 
      _id: 0, 
      hashTags: '$hashTags',
      highlights: { 
        "$meta": "searchHighlights" 
      }
    }

BUT, somehow the answer is a empty highlight array. When I use the “text” operator, the highlighting works perfectly.

I could not find any advice in the docs, so I though I ask the community :slight_smile:

Thanks in advice!

Hi @Sinan_Ayhan thanks for joining the community. At this time, autocomplete does not work with highlights. We are actively working on adding this functionality as we speak. It should be released in the next month or so.

2 Likes

Hello Marcus,

thank you very much for your answer!! I will stay tuned!
I would have another question, is it possible to use autocomplete with array of strings? Somehow it didn’t worked for me.

Best wishes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.