chore(search): address requested changes

This commit is contained in:
Elian Doran
2026-04-13 13:43:25 +03:00
parent 301f23cd2d
commit e40504b7f0
3 changed files with 12 additions and 4 deletions

View File

@@ -202,6 +202,11 @@ class BAttribute extends AbstractBeccaEntity<BAttribute> {
this.utcDateModified = dateUtils.utcNowDateTime();
// Recompute normalized fields in case name/value were modified directly
// (e.g., attr.value = "..." followed by attr.save())
this.normalizedName = normalize(this.name);
this.normalizedValue = normalize(this.value);
super.beforeSaving();
this.becca.attributes[this.attributeId] = this;

View File

@@ -595,10 +595,11 @@ function extractAttributeSnippet(noteId: string, searchTokens: string[], maxLeng
// Look for attributes that match the search tokens
for (const attr of attributes) {
const attrName = attr.name?.toLowerCase() || "";
const attrValue = attr.value?.toLowerCase() || "";
// Use pre-normalized fields from BAttribute for diacritic-insensitive matching
const attrName = attr.normalizedName || normalize(attr.name || "");
const attrValue = attr.normalizedValue || normalize(attr.value || "");
const attrType = attr.type || "";
// Check if any search token matches the attribute name or value
const hasMatch = searchTokens.some(token => {
const normalizedToken = normalize(token);

View File

@@ -282,7 +282,9 @@ export function fuzzyMatchWordWithResult(token: string, text: string, maxDistanc
// Exact match check first (most common case)
if (normalizedText.includes(normalizedToken)) {
return token;
// Find the exact match position and return the original substring with case preserved
const matchIndex = normalizedText.indexOf(normalizedToken);
return text.substring(matchIndex, matchIndex + normalizedToken.length);
}
// For fuzzy matching, split into words and check each against the token