Highlight() in Plain Indexes


I have plain indexes and highlight() isn’t working for some reason.

  • Highlight in HTTP: When specifying fields or not specifying fields -->Does not return highlights
  • Highlight in SQL: Only when specifying fields is when highlights are returned

Are highlighting features fully supported in plain indexes? Any recommendations about what to try to get highlighting results?

HTTP Request

“index”: “idx_dev”,
“limit”: 1,
“offset”: 0,
“profile”: false,
“query”: {
“match”: {
“p_last”: “smith”
“highlight”: {}

HTTP Response

“took”: 3,
“timed_out”: false,
“hits”: {
“total”: 96,
“hits”: [
“_id”: “99237962230916952”,
“_score”: 1667,
“_source”: {
“p_id”: 60001023,
“p_first”: “Robert”,
“p_middle”: “”,
“p_last”: “Smith”,
“p_full_name”: “Robert Smith”,
“ad_addresstype”: “”,
“ad_address1”: “54982 Smith Rd”,
“ad_city”: “Los Angeles”,
“ad_state”: “CA”,
“ad_zip”: “13245”,
“highlight”: {}

should wort as usual. Could you check your index config vs config at interactive course about highlighting to make sure you use stored fields ?

Thank you for your reply.
I followed the course and checked its manticore configuration then read about stored_fields. Based on that documentation, I went ahead and added to my plain index’s configuration:

stored_fields = p_full_name

When reindexing with indexer, I was getting:

ERROR: index ‘idx_dev’: existing attribute specified in stored_fields: ‘p_full_name’

I’m using sql_field_string for field p_full_name so it should be stored (based on this section of the documentation). This could be the reason behind the error. So, I assume that p_full_name is being stored in my plain index. Could the issue be related to something else?

sql_field_string creates full-text field and attribute with same name seems attribute clashes with stored field definition.

In case you do not filter or group on the p_full_name attribute it might be better to remove this attribute completely and keep only regular full-text field and mark it as stored too for highlight

If using sql_field_string then have an attribute, so could just use the original SNIPPET() function, rather than HIGHLIGHT()

(although dont know if SNIPPET() works with the HTTP interface, dont have any experience with it)