1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-08-28 08:10:54 +02:00

fix result highlighting #489

This commit is contained in:
Thomas Wilkerling
2025-04-17 10:09:16 +02:00
parent dafb137153
commit b75cccb0f8
26 changed files with 171 additions and 87 deletions

View File

@@ -267,4 +267,40 @@ if(!build_light) describe("Result Highlighting", function(){
}]
});
});
it("Should have been highlighted results properly (#489)", async function(){
const index = new Document({
encoder: Charset.LatinBalance,
document: {
store: true,
index: [
{
field: "title",
tokenize: "forward"
},
{
field: "content",
tokenize: "forward"
}
],
},
});
await index.addAsync({
id: 1,
title: "Tips For Decorating Easter Eggs",
content: `Published: April 14, 2025 From bold color choices to intricate patterns, there are many ways to make your springtime holiday decorations stand out from the rest. The Onion shares tips for dyeing Easter eggs.`
});
const search = await index.search("h", {
suggest: true,
enrich: true,
highlight: `<mark>$1</mark>`,
});
expect(search.length).to.equal(1);
expect(search[0].result.length).to.equal(1);
expect(search[0].result[0].highlight).to.equal('Publis<mark>h</mark>ed: April 14, 2025 From bold color c<mark>h</mark>oices to intricate patterns, t<mark>h</mark>ere are many ways to make your springtime <mark>h</mark>oliday decorations stand out from t<mark>h</mark>e rest. T<mark>h</mark>e Onion s<mark>h</mark>ares tips for dyeing Easter eggs.');
});
});