#community-help

Duplicate Highlight Keys in Search Results

TLDR Manish noticed two highlight keys in search results. Jason explained "highlight" is the newer key for nested fields, while "highlights" is for backward compatibility.

Powered by Struct AI

1

3
6mo
Solved
Join the chat
May 26, 2023 (6 months ago)
Manish
Photo of md5-f0a83cd20895941fd74c026f9f15b61f
Manish
05:43 PM
I'm looking at the search results, and it seems to have two different highlight keys. One called "highlight" and another called "highlights". Both seem to have the same data.

      "highlight": {
        "chats": {
          "matched_tokens": [
            "help",
            "docker"
          ],
          "snippet": "wondering if anyone could <mark>help</mark> me configure my <mark>docker</mark> hosted typesense with SSL"
        },
        "summary": {
          "matched_tokens": [
            "help"
          ],
          "snippet": " Ian asked for <mark>help</mark> with setting up SSL certificates in a Docker-hosted Typesense.  Jason provided suggestions but the issue remains unresolved due to port conflict."
        }
      },
      "highlights": [
        {
          "field": "chats",
          "matched_tokens": [
            "help",
            "docker"
          ],
          "snippet": "wondering if anyone could <mark>help</mark> me configure my <mark>docker</mark> hosted typesense with SSL"
        },
        {
          "field": "summary",
          "matched_tokens": [
            "help"
          ],
          "snippet": " Ian asked for <mark>help</mark> with setting up SSL certificates in a Docker-hosted Typesense.  Jason provided suggestions but the issue remains unresolved due to port conflict."
        }
      ],

Why is this?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:07 PM
highlight is the newer key which you want to use, which we had to update to once we launched the ability to index nested fields.

We’ve kept the older highlights key for backward compatibility purposes. This key won’t contain any highlights for nested objects.

We plan to deprecate the highlights key several versions from now…

1

Manish
Photo of md5-f0a83cd20895941fd74c026f9f15b61f
Manish
06:09 PM
I see. Makes sense.