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.fullTextIndex = lunr(function(){
|
||||||
this.ref("id")
|
this.ref("id")
|
||||||
this.field("name")
|
this.field("name", {boost: 3})
|
||||||
|
this.field("name_simple", {boost: 2})
|
||||||
this.field("synonyms")
|
this.field("synonyms")
|
||||||
|
|
||||||
for(let [id, feature] of Object.entries(database.featuresById)){
|
for(let [id, feature] of Object.entries(database.featuresById)){
|
||||||
let sym = feature.mapSymbol;
|
let sym = feature.mapSymbol;
|
||||||
|
|
||||||
let synonyms = []
|
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){
|
if(sym.genericName){
|
||||||
synonyms.push(sym.genericName)
|
synonyms.push(sym.genericName)
|
||||||
|
|
@ -200,11 +213,18 @@ export class PlaceDatabase extends EventTarget {
|
||||||
showOnEmptyMap.push(feature)
|
showOnEmptyMap.push(feature)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let boost = undefined;
|
||||||
|
|
||||||
|
if(sym.searchBoost !== undefined){
|
||||||
|
boost = sym.searchBoost
|
||||||
|
}
|
||||||
|
|
||||||
this.add({
|
this.add({
|
||||||
id,
|
id,
|
||||||
name: feature.properties.name || sym.genericName,
|
name: feature.properties.name || sym.genericName,
|
||||||
|
name_simple,
|
||||||
synonyms
|
synonyms
|
||||||
})
|
}, {boost})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,11 @@ export class MapSymbol {
|
||||||
*/
|
*/
|
||||||
genericName = undefined
|
genericName = undefined
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boost features with this symbol up (or down if negative) in search if defined
|
||||||
|
*/
|
||||||
|
searchBoost = undefined
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of sysnonyms for this feature for full text indexing
|
* A list of sysnonyms for this feature for full text indexing
|
||||||
* @type {string[]}
|
* @type {string[]}
|
||||||
|
|
@ -300,6 +305,7 @@ export const VERBOTEN_AREA_SYMBOL = new MapSymbol()
|
||||||
VERBOTEN_AREA_SYMBOL.genericName = "Zone interdite"
|
VERBOTEN_AREA_SYMBOL.genericName = "Zone interdite"
|
||||||
VERBOTEN_AREA_SYMBOL.backgroundColor = "#992700"
|
VERBOTEN_AREA_SYMBOL.backgroundColor = "#992700"
|
||||||
VERBOTEN_AREA_SYMBOL.borderColor = "#992700"
|
VERBOTEN_AREA_SYMBOL.borderColor = "#992700"
|
||||||
|
VERBOTEN_AREA_SYMBOL.searchBoost = -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BUILDING_SYMBOL = new MapSymbol()
|
export const BUILDING_SYMBOL = new MapSymbol()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue