I'm trying to understand how to limit what comes b...
# community-help
t
I'm trying to understand how to limit what comes back on the search results for the
highlight
property I have a collection with a schema where
{ name: 'titles', type: 'string[]' }
(and many other properties, but the
string[]
is my hangup) what I would like is that, when I query for, say
q=cheese&query_by=titles
that each returned hit includes only the matches for
titles
and not every
titles
element for the document I spent some time looking through the results parameters section, but couldn't figure out what incantation to use 😞
for example, I was trying different combinations of these query params
Copy code
GET {baseUrl}/collections/essays/documents/search?query_by=titles&q=cheese&exclude_fields=titles&highlight_fields=titles&highlight_full_fields=titles
but what I'd get back, in truncated form, looks like this
Copy code
{
  // [...snip...]
  "hits": [
    {
      "document": {
        // not the `titles`, which is good
      },
      // this one is good, it only has this
      "highlights": [
        {
          "field": "titles",
          "indices": [ 91 ],
          "matched_tokens": [
            [ "cheese" ]
          ],
          "snippets": [
            "the <mark>cheese</mark> in the rat trap"
          ]
        }
      ],
      // this is the one I want to get rid of
      "highlight": {
        "titles": [
          // or at least not include 
          {
            "matched_tokens": [],
            "snippet": "things unrelated to dairy"
          },
          // there are many here without matched tokens
        ]
      }
    }
  ]
}