Boost responses by country code
:wave: I did some awesome work for the Pelias project and would love for everyone to have a look at it and provide feedback.
Here's the reason for this change :rocket:
closes pelias/pelias#944
Here's what actually got changed :clap:
I added the query paramater focus.country and focus.gid available only with autocomplete API. This will apply a defined boost set to 1.5 and not customizable. I did some tests and seems to be correct. I also tried 1.25 and 2
Here's how others can test the changes :eyes:
Some examples with focus.country
/v1/autocomplete?focus.country=fra&size=3&text=13 allée France addresses are in first position
// from
0) Alleestraße 13, Potsdam, BB, Allemagne
1) Alleestraße 13, Putbus, MV, Allemagne
2) Al Molo 13, Capriate San Gervasio, BG, Italie
//to
0) 13 Allée Louis 13, Maubeuge, France
1) 13 Allee De 13 Vents, Le Breuil-sur-Couze, France
2) 13 Allee Marguerite De Flandre(1-13), Prémesques, France
/v1/autocomplete?focus.country=usa&size=5&lang=en&text=paris USA documents before Jamaica, but Paris in France still in first position
// from
0) Métropole du Grand Paris, France
1) Paris, France
2) Saint Andrew, Jamaica
3) Saint Catherine, Jamaica
4) East Baton Rouge Parish, LA, USA
//to
0) Métropole du Grand Paris, France
1) Paris, France
2) East Baton Rouge Parish, LA, USA
3) Jefferson Parish, LA, USA
4) Orleans Parish, LA, USA
/v1/autocomplete?focus.country=gb&size=5&lang=en&text=melbourne same as Paris, Melbourne is still in first position, but now we see cities from UK
// from
0) Melbourne, VIC, Australia
1) Melbourne, FL, USA
2) Melbourne City Centre, Melbourne, VIC, Australia
3) West Melbourne, FL, USA
4) Port Melbourne, VIC, Australia
// to
0) Melbourne, VIC, Australia
1) Melbourne, England, United Kingdom
2) Melbourne, England, United Kingdom
3) Melbourne, FL, USA
4) Melbourne City Centre, Melbourne, VIC, Australia
Some examples with focus.gid
/v1/autocomplete?focus.gid=whosonfirst:localadmin:1377689997&size=5&text=Starbucks Focus on Aachen in Germany
// from
0) Starbucks, West Drayton, England, United Kingdom
1) Starbucks, Jenjarom, SGR, Malaysia
2) Starbucks, Aachen, NW, Germany
3) Starbucks, Shah Alam, SGR, Malaysia
4) Starbucks, Seattle, WA, USA
//to
0) Starbucks, Aachen, NW, Germany
1) Starbucks, West Drayton, England, United Kingdom
2) Starbucks, Jenjarom, SGR, Malaysia
3) Starbucks, Shah Alam, SGR, Malaysia
4) Starbucks, Seattle, WA, USA
/v1/autocomplete?focus.gid=whosonfirst:region:85688651&size=5&lang=en&text=melbourne just like
focus.countrythis will change the order of result but not replace very high ranking (focus on Florida)
// from
0) Melbourne, VIC, Australia
1) Melbourne, FL, USA
2) Melbourne City Centre, Melbourne, VIC, Australia
3) West Melbourne, FL, USA
4) Port Melbourne, VIC, Australia
//to
0) Melbourne, VIC, Australia
1) Melbourne, FL, USA
2) West Melbourne, FL, USA
3) Melbourne Beach, FL, USA
4) Melbourne City Centre, Melbourne, VIC, Australia
I had to change a test in test/unit/helper/diffPlaces.js, IDK why :shrug:
I've just added the support of focus.gid and updated the PR description with new examples.
I thik this is good to go now :smile:
Can I have feedback on this PR ? Is the API OK for you ?
Hi @Joxit, sorry I'm super busy this week (Berlin Buzzwords) and next week I'm off to Kosovo (FOSS4G).
I'll try and have a look over it while I'm away next week.
FYI I think the test issue with the Eszett is caused by https://github.com/tyxla/remove-accents/issues/12
Okay, thanks for your response :smile:
Heya, I just got back from Kosovo and super exhausted, just wanted to send you a quick note that this is on my todo list.
Hi Peter, thank you for your update! I've sync the branch with master according to #1655
Rest well :wink:
These API params are available for /v1/autocomplete but not /v1/search, we've been moving toward having parity between the two APIs so I think it might be nice to have this also available for search?
I noticed that there are no new tests in test/unit/fixtures, could we add a couple fixtures please? they make understanding how the queries get generated easier and also help prevent someone else coming along and breaking this feature in the future 🙏
Hi Pete, thank you for your comments. I removed the function_score from the query and added tests + fixtures :rocket:
For the /search endpoint and the two step search (first one with placeholder and second with ES) I don't know which behavior the API should have when placeholder is used.
Currently, the result for /v1/search?size=5&lang=en&text=paris is
Paris, France
Paris, TX, USA
Paris, ON, Canada
Paris, TN, USA
Swainsboro, GA, USA
If we add a focus.country=USA and say "every results in the USA goes first" (since we do not score results here) Paris, France will completely disappear because placeholder send 15 results in USA... :confused:
This is a bit tricky IMO and I don't know the correct way to do it for now...
However when search uses ES, this should be ok :smile: