Azure Maps fuzzy search results are not limited to bounding box

Jeremiah Mercier 21 Reputation points
2023-01-06T18:12:32.813+00:00

When I perform a fuzzy search using the Azure Maps REST API, the results are not limited to the bounding box I specify. This makes searching for partial addresses much less useful, since many/most/all of the results are from other states and the relevant results from the specified state are not included in the first 10-20 results.

For example, if I search for "123 Main" and specify a bounding box that covers the state of Louisiana, I should get a half dozen or so point addresses in the results, and all the results should be constrained to the bounding box. (There may be a few results from the edges of surrounding states since the bounding box is a rectangle.) Instead, I get results from Connecticut, Ohio, Massachusetts, and so on that are clearly outside the bounding box.

The documentation clearly states, "You can use the btmRight and topleft parameters to set the bounding box. These parameters restrict the search to a specific area on the map."

https://learn.microsoft.com/en-us/azure/azure-maps/how-to-use-best-practices-for-search#limit-search-results
https://learn.microsoft.com/en-us/rest/api/maps/search/get-search-fuzzy

The test query I am using is:

https://atlas.microsoft.com/search/fuzzy/json?subscription-key=[SUBSCRIPTION_KEY]&api-version=1.0&query=123+Main&countrySet=US&idxSet=Addr,PAD,POI,XStr&lat=30.3618&limit=20&lon=-91.1067&typeahead=true&topLeft=33.019457,-94.043147&btmRight=28.928609,-88.817017

Am I doing something wrong? How do I limit the search results to the bounding box?

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
836 questions
{count} votes

2 answers

Sort by: Most helpful
  1. rbrundritt 20,921 Reputation points Microsoft Employee Moderator
    2023-01-06T22:34:07.473+00:00

    The bounding box is meant to help influence the relevance of the results and is not a filter.

    1 person found this answer helpful.

  2. Kevin Flood 51 Reputation points
    2023-05-05T09:45:03.8+00:00

    @Jeremiah Mercier I'd noticed this issue too i.e. issues with GeoBiasing and issue when using lat&lon params cancels/overrides topLeft&topRight params.

    I agree with you that it's a real issue and was not behaving as intended. I don't think it was a documentation mistake. I also think the suggested fix to use countrySet param was essentially a hack to give "better" results.

    However, the issue appears to have been resolved now. Using your examples above:

    1. Using topLeft&topRight params only

    https://atlas.microsoft.com/search/fuzzy/json?subscription-key=SUBSCRIPTION_KEY&api-version=1.0&query=123+Main&idxSet=Addr,PAD,POI,XStr&limit=20&typeahead=true&topLeft=33.019457,-94.043147&btmRight=28.928609,-88.817017

    Gives result:

    Selection_468

    1. Using both topLeft&topRight params and lat&lon params:

    https://atlas.microsoft.com/search/fuzzy/json?subscription-key=SUBSCRIPTION_KEY&api-version=1.0&query=123+Main&idxSet=Addr,PAD,POI,XStr&limit=20&typeahead=true&topLeft=33.019457,-94.043147&btmRight=28.928609,-88.817017&lat=30.3618&lon=-91.1067

    Selection_470

    Notes:

    1. The countrySet param has not been used in either of these examples yet the result are what you'd expect. This param is now only really required if you have a usecase where you need a further filter so that, for example, you only want to return results on one side of a national border even though the view covers more than one country.
    2. The lat lon bias (green marker) now works with the bounding box params.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.