MongoDB.live, free & fully virtual. Register Now MongoDB.live, free & fully virtual. Register Now

Highlight Missing

Am using Atlas and doing some searches - working all fine. However I am looking to return the highlights - which sometimes work - and sometimes don’t. Search is working insofar as it is finding the documents that contain the terms, however it appears that is the terms are ‘too far in’ (the text is often long), and highlights are not returned.

Not sure if I have made an error or there is a known bug (?) or if anyone else has stumbled across this issue. Here is (a somewhat modified) snippet:

$search: {
            "compound": {
              "must": [{
                "queryString": {
                  "defaultPath": "text",
                  "query": paramMust
                }
              }],
              "mustNot": [{
                "text": {
                  "query": paramMustNot,
                  "path": ["text", "name"],
                }
              }],
              "should": [{
                "text": {
                  "query": paramShould,
                  "path": ["text", "name"],
                  "fuzzy": {
                    "maxEdits": maxEdits,
                    "maxExpansions": maxExpansions,
                  }
                }
              }]
            },
            "highlight": {
              "path": "text",
            }
          }
        },
        {
          $project: {
            "_id": 1,
            "name": 1,
            "highlights": { "$meta": "searchHighlights" }
          }
        }

After many hours of toiling I found a highlight that returned - half a sentence - I believe not expected behaviour! This leads me to believe perhaps if it doesn’t find the term in the first x characters then it goes ‘ah well, too hard’ and returns no highlights. Whilst I could parse the text myself and do my own deconstruction, this feels sub-optimal when there is a highlighting feature.

Hi @Simon_Kun. I’m the Product Manager for Atlas Search. It looks like you have found a bug but we have a fix. We should be able to release it next week. Thank you very much for reporting.

Right now, we only return the top five highest scoring passages for a field when highlighting. Furthermore, if the length of your field is longer than 10,000 characters, only the first 10,000 characters will be examined for highlighting. This information is currently not in our docs and we apologize for that, but that information should be out next week as well.

If you run into any other issues on Atlas Search be sure to let us know.

1 Like