Skip to content

Commit 85643c7

Browse files
author
Alejandro Hernandez
committed
Add ability to specify elastic results highlight tags
1 parent ca0b3ea commit 85643c7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.changeset/eighty-games-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'contexture-elasticsearch': minor
3+
---
4+
5+
Add ability to specify elastic results highlight tags

packages/provider-elasticsearch/src/example-types/results/highlighting/search.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ import {
1111
getResponseHighlight,
1212
} from './response.js'
1313

14-
let tags = {
15-
pre: '<b class="search-highlight">',
16-
post: '</b>',
17-
}
18-
1914
export let searchWithHighlights = (node, search, schema) => async (body) => {
2015
// Paths for fields to always include regardless of whether the user included
2116
// them. They will be removed from the response hits so the user will not
@@ -33,6 +28,11 @@ export let searchWithHighlights = (node, search, schema) => async (body) => {
3328
pathsToAdd
3429
)
3530

31+
let tags = {
32+
pre: node.highlight?.tags?.pre ?? '<em class="search-highlight">',
33+
post: node.highlight?.tags?.post ?? '</em>',
34+
}
35+
3636
let response = await search({
3737
...body,
3838
_source: F.omitBlank(source),

0 commit comments

Comments
 (0)