Diacritiques ignorés dans la recherche et ajustement des boosts
This commit is contained in:
parent
f677fba85a
commit
0db54f17cd
2 changed files with 28 additions and 2 deletions
24
js/places.js
24
js/places.js
|
|
@ -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})
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue