Marqo _highlights return type differs between LEXICAL and TENSOR search

The _highlights field in Marqo search results had different types depending on the search method. Reading results['hits'][0]['_highlights'] returned a dict for the default TENSOR search but an empty list for search_method='LEXICAL'. This made client code that consumed highlights method-dependent and fragile. A community member proposed the fix and a maintainer invited a PR.

This inconsistency was fixed in Marqo v2, where the _highlights return type was made consistent across search methods. If you are on Marqo v1, the workaround is to handle both types client-side; upgrading to v2 resolves it. Source: https://github.com/marqo-ai/marqo/issues/70

Source: https://github.com/marqo-ai/marqo/issues/70