typesense / typesense-instantsearch-adapter

A JS adapter library to build rich search interfaces with Typesense and InstantSearch.js
MIT License
414 stars 64 forks source link

highlight_fields causing them to be shown as 'undefined' #65

Closed dianos closed 2 years ago

dianos commented 3 years ago

Description

highlight_fields causing them to be shown as 'undefined'

Steps to reproduce

if the field is not in queryBy: "description,concat" it's shown as undefined when there is a highlight. in this case: highlight_fields:"name,description,concat",

Typsense Version: 0.22.rc6 "typesense-js": "^0.14.0", "typesense-instantsearch-adapter": "^2.0.1"

OS: linux ubuntu

note: earlier versions of the typesense js libraries were showing all these fields as undefined even if there was no highlight.

jasonbosco commented 3 years ago

@dianos If you use highlight_fields (which means results will be highlighted with snippetting), you'd need to use the Snippet widget to access the results.

dianos commented 3 years ago

yes replacing helpers.highlight with helpers.snippet works, thx :)

dianos commented 3 years ago

Snippet causes text in the field to be cut short. Is there a way to highlight full fields that are not in queryBy?

jasonbosco commented 3 years ago

Snippet causes text in the field to be cut short.

Yes, this is by design. Snippet is to show a small portion of the text around the match text. To get the full field, you need to use highlight full fields and helpers.highlight

Is there a way to highlight full fields that are not in queryBy?

You can set additionalSearchParameters.highlightFullFields to include all the fields you want to be highlighted.