Skip to content

Commit febf489

Browse files
committed
Handle case where only snippeting is enabled (eg in presets), fall back to snippet value when highlight is requested
1 parent afa226b commit febf489

9 files changed

+18
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
368368
## Compatibility
369369

370370
| Typesense Server | typesense-instantsearch-adapter | instantsearch.js | react-instantsearch | vue-instantsearch | angular-instantsearch |
371-
|------------------|---------------------------------|------------------|---------------------|-------------------|-----------------------|
371+
| ---------------- | ------------------------------- | ---------------- | ------------------- | ----------------- | --------------------- |
372372
| \>= v0.24 | \>= v2.5.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
373373
| \>= v0.21 | \>= v2.0.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
374374
| \>= v0.19 | \>= v1.0.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |

dist/typesense-instantsearch-adapter.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/typesense-instantsearch-adapter.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/typesense-instantsearch-adapter.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/typesense-instantsearch-adapter.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/SearchResponseAdapter.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/SearchResponseAdapter.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SearchResponseAdapter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ export class SearchResponseAdapter {
209209
if (highlightPrimitiveValue != null) {
210210
return {
211211
value: this._adaptHighlightTag(
212-
`${highlightPrimitiveValue[snippetOrValue]}`,
212+
`${
213+
highlightPrimitiveValue[snippetOrValue] ??
214+
highlightPrimitiveValue["highlight"] ??
215+
highlightPrimitiveValue["snippet"]
216+
}`,
213217
this.instantsearchRequest.params.highlightPreTag,
214218
this.instantsearchRequest.params.highlightPostTag
215219
),

test/support/data/typesense-search-response-with-highlight-to-0.24.0-rcn32-and-above.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,15 @@
3535
"matched_tokens": [
3636
"Houston"
3737
],
38-
"snippet": "<mark>Houston</mark>",
39-
"value": "<mark>Houston</mark>"
38+
"snippet": "<mark>Houston</mark>"
4039
}
4140
}
4241
],
4342
"company_name": {
4443
"matched_tokens": [
4544
"Stark"
4645
],
47-
"snippet": "<mark>Stark</mark> Industries",
48-
"value": "<mark>Stark</mark> Industries"
46+
"snippet": "<mark>Stark</mark> Industries"
4947
}
5048
},
5149
"highlights": [

0 commit comments

Comments
 (0)