-
-
Notifications
You must be signed in to change notification settings - Fork 520
Open
Description
First, thank you for this library and its rich API. I've spent several days carefully studying the documentation and have implemented most of my desired functionality. However, I'm encountering a confusing highlighting result that I can't resolve.
Minimal Reproduction:
import { Document, Charset } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.module.min.js";
const data = [
{ "id": 1, "title": "Carmencita" },
{ "id": 2, "title": "en-US.json" }
];
const index = new Document({
document: {
store: true,
index: [{
field: "title",
// tokenize: "full",
// encoder: Charset.Default
}]
}
});
data.forEach(item => index.add(item));
const result = index.search({
query: 'en',
enrich: true,
highlight: { template: "<b>$1</b>" }
});Actual Result:
[
{
"field": "title",
"result": [
{
"id": 2,
"doc": {
"id": 2,
"title": "en-US.json"
},
"highlight": "<b>e</b>n-US.json"
}
]
}
]Expected Behavior:
When searching for "en", I expect the highlight to wrap the entire matched term:
"highlight": "<b>en</b>-US.json"
Troubleshooting Attempted:
- Adjusted
tokenizeoption (tried"full"and defaults) - Tested different
encodersettings (includingCharset.Default) - Verified with multiple term lengths (always highlights only first character)
The issue persists regardless of configuration. Could someone please advise if I'm missing something or if this is a potential bug? Any guidance would be greatly appreciated!
ts-thomas and Wxh16144Wxh16144
Metadata
Metadata
Assignees
Labels
No labels