Diacritiques ignorés dans la recherche et ajustement des boosts

This commit is contained in:
EpicKiwi 2026-06-28 17:20:22 +02:00
parent f677fba85a
commit 0db54f17cd
Signed by: epickiwi
GPG key ID: C4B28FD2729941CE
2 changed files with 28 additions and 2 deletions

View file

@ -180,13 +180,26 @@ export class PlaceDatabase extends EventTarget {
this.fullTextIndex = lunr(function(){
this.ref("id")
this.field("name")
this.field("name", {boost: 3})
this.field("name_simple", {boost: 2})
this.field("synonyms")
for(let [id, feature] of Object.entries(database.featuresById)){
let sym = feature.mapSymbol;
let synonyms = []
let name_simple = null;
if(feature.properties.name){
let sinDiacritics = feature.properties.name.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "");
name_simple = sinDiacritics.toLowerCase();
synonyms.push(feature.properties.name.toLowerCase())
synonyms.push(sinDiacritics)
synonyms.push(sinDiacritics.toLowerCase())
}
if(sym.genericName){
synonyms.push(sym.genericName)
@ -200,11 +213,18 @@ export class PlaceDatabase extends EventTarget {
showOnEmptyMap.push(feature)
}
let boost = undefined;
if(sym.searchBoost !== undefined){
boost = sym.searchBoost
}
this.add({
id,
name: feature.properties.name || sym.genericName,
name_simple,
synonyms
})
}, {boost})
}
})