Fallback in highlight_fields not working as documented

(basically the same issue as reported here - Highlight fields not matching multiple words - #2 by JasonStoltz)

When querying using highlight_fields, for a non-exact match, I would expect that setting fallback=true would cause the search response to include raw data in the highlight field.

(as per docs - Highlight Fields | Swiftype Documentation)

What we actually see is that the highlight field in the response is empty. The demo shown at https://search-ui-stable-site-search.netlify.com/?q=100-mile&size=n_20_n is "cheating" - when it receives nothing in the highlight field, it substitutes the body of the search response document.

In the image below we searched for "100 mile" (unquoted) and the highlighter worked properly.

When we search for "100-mile" (unquoted), the search response does not contain highlight data - and the body content is substituted by the front-end.

Request fragment:

curl 'https://search-api.swiftype.com/api/v1/public/engines/search.json' \
  -H 'Accept: */*' \
  -H 'Content-Type: application/json' \
  --data '{"engine_key":"Z43R5U3HiDsDgpKawZkA","per_page":20,"page":1,"facets":{"national-parks":["world_heritage_site","states"]},"fetch_fields":{"national-parks":["visitors","world_heritage_site","location","acres","square_km","title","nps_link","states","date_established","description"]},"highlight_fields":{"national-parks":{"title":{"size":100,"fallback":true},"description":{"size":100,"fallback":true}}},"q":"100-mile"}'

image

Response fragment:
image

Good catch Ben, I'll put in an issue and see that we get this fixed.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.