Specify a province for Places autocompletion and allow incomplete words

Hi,

we’ve integrated Algolia Places to use for an address field autocomplete and I love how simple it was to integrate it. Our business is based in Quebec, Canada, and I’ve set the countries array (config option) to only Canada ( ca ).

However, by default the top results shown are from Alberta. Is there a way to specify a province so that results from Quebec are weighted higher and thus appear first in the suggestions?

Also, another issue we’re having is that the autocomplete won’t work properly if the user enters partial words for the street names, such as “Boulevard”.

Example, if the user types boul henri-bourassa in the search field, we’d expect to see Boulevard Henri-Bourassa at the top, but since the Boulevard word was only partially typed out, it won’t find the proper result.

Is this the expected behaviour, or do I need to tweak some option/config so that it tolerates those partially-completed words?

Google Maps supports that and at the moment this is the only thing preventing us to switch to Places.

Thanks for the help!

Hi :wave:

You can restrict the search to a specific region, but it will exclude results outside of it. There is no way to change the ranking formula at query time. Would you say the ranking for Canada isn’t right in general or for your use case?

About boul, we do handle the following synonyms for boulevard: bl, bld, blv, blvd. I’m adding boul to the list!

If you have other similar issues, don’t hesitate to open an issue on Github https://github.com/algolia/places

Thanks for your contribution!

Hi,

first off, thanks for the fast reply and for adding boul to the list of synonyms for boulevard. :slight_smile:

You can restrict the search to a specific region, but it will exclude results outside of it. There is no way to change the ranking formula at query time.

Could I use aroundLatLng with a very large aroundRadius to trick it into displaying the results near me first? I don’t want to limit the results to only that, but obviously in most cases the user will want the address that is closest to them, yet there’s still a slight chance that they will want an address from another province completely.

Would you say the ranking for Canada isn’t right in general or for your use case?

I can’t really say as I haven’t used it extensively, but all the top results seemed to be from Alberta for some reason. Maybe because they’re in alphabetical order when there’s nothing better to use initially?

Could I use aroundLatLng with a very large aroundRadius to trick it into displaying the results near me first? I don’t want to limit the results to only that, but obviously in most cases the user will want the address that is closest to them, yet there’s still a slight chance that they will want an address from another province completely.

You are actually describing the default behavior of the engine for Places :slight_smile: It is already supposed to work this way (see the doc).

Now if you really want to force it, or ponderate it more in the user’s area, you could do the trick you described + merging the default results.

I can’t really say as I haven’t used it extensively, but all the top results seemed to be from Alberta for some reason. Maybe because they’re in alphabetical order when there’s nothing better to use initially?

We do not rank alphabetically so it’s another issue. Could you give me a search term example and the expected result? It will be easier to see why Alberta results are coming up first.

Maybe the IP resolution is incorrect, so if you provide the user’s real coordinates through aroundLatLng, it might get better.

PS: we just released a few minutes ago; you can now use the boul synonym :wink:

1 Like

Sure!

For example, I might want to search for 9500 boulevard <name>, so I will start by typing 9500 (with a space after). I expect addresses starting with 9500 to be at the top, but I only see addresses starting with 900 and all in Calgary, AB

Of course, it’s not a huge deal since I don’t expect it to find the right address just by typing the street number, but I’m still wondering why all the results are in Calgary when there are definitely some addresses that start by 9500 near me, in Quebec.

Thanks for the help!

Edit

Apparently it’s a bigger issue. I tried specifying a location and a radius, like so :

let placesAutocomplete = Places({
  container: document.querySelector('#address'),
  type: 'address',
  countries: ['ca'],
  aroundLatLng: '45.516113, -73.563253',
  aroundRadius: 100000,
});

But now, if I only type 9500 in the search box, I get no results at all. As soon as I add the boul part, then the results come back and they’re ordered/filtered as I want them to.

What am I doing wrong?

Alright this is interesting. Sorry for the delay in responding, this took me actually more time to debug than I first expected.

There are different issues mixed up here:

  1. When just typing the house number, the engine prefers to not bring up results contained in a <placeholder> to avoid noisy results. This might be relevant for a regular Algolia index, but for Places I think it actually makes sense to return nearby results anyway.
  2. The engine found the first results that are not contained in the house number <placeholder> in Alberta. That’s actually a bug where the house number wasn’t correctly replaced by a <placeholder>. I’ve opened an issue internally to track that down.
  3. Typo-tolerance on numerics is enabled, which is why you see the 900 highlighted when you actually typed 9500. This is a setting I’ve been thinking of tweaking for some time, and that’s an additional reason to do so.

Just to make sure: if you type 9500 b you start to get results from Quebec correct?

Is the boul working now?

Thank you again for reporting this, it really helps getting a better geocoder.

Thank you for the fast rely and tracking this bug down!

Just to make sure: if you type 9500 b you start to get results from Quebec correct?

Yes, as soon as I type the B the first results are from Quebec and also properly ordered (closest next to me first, I assume it’s using the IP for that)

Is the boul working now?

Yes that works too!

Feel free to post an update in this topic when you know more about this issue and when it might be/is resolved.

Thanks!