1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-08-27 15:50:44 +02:00

highlighting merged document results

This commit is contained in:
Thomas Wilkerling
2025-05-14 08:28:38 +02:00
parent 9053b2c834
commit 4a59a9a027
128 changed files with 3601 additions and 8090 deletions

View File

@@ -840,6 +840,66 @@ if(!build_light) describe("Result Highlighting", function(){
expect(result[1].highlight.length).to.below(80 + (7 * 7));
});
it("Should have been highlighted merged results properly", function(){
// some test data
const data = [{
"id": 1,
"title": "Carmencita",
"description": "Description: Carmencita"
},{
"id": 2,
"title": "Le clown et ses chiens",
"description": "Description: Le clown et ses chiens"
}];
// create the document index
const index = new Document({
encoder: Charset.LatinBalance,
document: {
store: true,
index: [{
field: "title",
tokenize: "forward"
},{
field: "description",
tokenize: "forward"
}]
}
});
// add test data
for(let i = 0; i < data.length; i++){
index.add(data[i]);
}
let result = index.search({
query: "karmen or clown or not found",
suggest: true,
enrich: true,
merge: true,
highlight: "<b>$1</b>"
});
expect(result).to.eql([{
id: 1,
doc: data[0],
field: ["title", "description"],
highlight: {
"title": '<b>Carmen</b>cita',
"description": 'Description: <b>Carmen</b>cita',
}
},{
id: 2,
doc: data[1],
field: ["title", "description"],
highlight: {
"title": 'Le <b>clown</b> et ses chiens',
"description": 'Description: Le <b>clown</b> et ses chiens',
}
}]);
});
it("Should have been highlighted results properly (#480)", function(){
const index = new Document({