Can I do highlighting in the objectID?

The response object doesn’t include the id or objectID even if it is specified under attributesToHighlight. Is there a way to get it returned?

As a unique identifier, the objectID is a special attribute that is excluded from most of Algolia’s processing. In particular, it won’t be highlighted (nor snippeted). It cannot be faceted either (but this would make little sense anyway since every count would be one). An important exception is that it can be used as a facet filter (even if it is not declared in attributesForFaceting).

If you really need to search and highlight the object ID, we encourage you to duplicate its value to another attribute, and include that attribute in searchableAttributes and attributesToHighlight.

1 Like