Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer a way to retrieve the name that matched the query #619

Open
AdrienVH-c2c opened this issue Apr 30, 2020 · 1 comment
Open

Offer a way to retrieve the name that matched the query #619

AdrienVH-c2c opened this issue Apr 30, 2020 · 1 comment
Assignees

Comments

@AdrienVH-c2c
Copy link
Contributor

AdrienVH-c2c commented Apr 30, 2020

It would be great if it there was a way to retrieve the name that matched the query, like a new "matched_name_position" attribute :

// Pour /search/?q=ecole+anne+frank
"properties": {
    "label" : "Ecole Anne Frank 93250 Villemomble"
    "name" : ["Ecole Anne Frank", "Ecole de la Carrière", "Ecole du Parc"],
    "matched_name_position" : 0,
    "postcode" : "93250",
    "city" : "Villemomble"
    ...
}

// Pour /search/?q=ecole+carriere
"properties": {
    "label" : "Ecole Anne Frank 93250 Villemomble"
    "name" : ["Ecole Anne Frank", "Ecole de la Carrière", "Ecole du Parc"],
    "matched_name_position" : 1,
    "postcode" : "93250",
    "city" : "Villemomble"
    ...
}

// Pour /search/?q=ecole+du+parc
"properties": {
    "label" : "Ecole Anne Frank 93250 Villemomble"
    "name" : ["Ecole Anne Frank", "Ecole de la Carrière", "Ecole du Parc"],
    "matched_name_position" : 2,
    "postcode" : "93250",
    "city" : "Villemomble"
    ...
}

Thus, we would be able, in our front app, to display the "matched name" whenever the matched_name_position value is greater than 0 :

var customLabel = result.properties.name[0];
var matchedNamePosition = result.properties.matched_name_position;
if(matchedNamePosition > 0){
    var matchedName = result.properties.name[matchedNamePosition]
    customLabel += ' (anc. ' + matchedName + ')'
}
// Pour /search/?q=ecole+anne+frank, customLabel = "Ecole Anne Frank"
// Pour /search/?q=ecole+carriere, customLabel = "Ecole Anne Frank (anc. Ecole de la Carrière)"
// Pour /search/?q=ecole+du+parc, customLabel = "Ecole Anne Frank (anc. Ecole du Parc)"

Originally posted by @AdrienVH-c2c in #617 (comment)

@ericlecoutre
Copy link

That would also be useful for my usage of addok that handles Belgium multilinguism.

@cquest cquest self-assigned this Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants