Skip to content

Commit 0fee51e

Browse files
committed
Add dertails on get geocoding section.
1 parent 1c76a93 commit 0fee51e

1 file changed

Lines changed: 81 additions & 7 deletions

File tree

articles/azure-maps/how-to-use-best-practices-for-search.md

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ You can use any API development environment such as [Bruno] to run the HTTP requ
990990

991991
### Task‑specific operations
992992

993-
Each Search capability is exposed through a dedicated API, such as [Get Geocoding], [Get Geocode Autocomplete], or [Get Reverse Geocoding]. This separation improves clarity, performance, and intent alignment.
993+
Each Search capability is exposed through a dedicated API, such as [Get Geocoding], [Get Geocode Autocomplete], [Get Reverse Geocoding] or [Get Polygon]. This separation improves clarity, performance, and intent alignment.
994994

995995
### Geographic relevance signals
996996

@@ -1004,23 +1004,94 @@ Batch APIs allow multiple queries in a single request for large‑scale workload
10041004

10051005
Use [Get Geocoding] when converting an address or place name into geographic coordinates.
10061006

1007-
Recommendations:
1007+
Forward geocoding example request using the `query` parameter:
1008+
1009+
```rest
1010+
GET https://atlas.microsoft.com/geocode
1011+
?api-version=2026-01-01
1012+
&query=140th%20Ave%20NE%2C%20Redmond
1013+
&top=1
1014+
&subscription-key={Your-Azure-Maps-Key}
1015+
```
1016+
1017+
### Improve result quality for query-based geocoding
10081018

1009-
* Provide the most complete address string available.
1010-
* Use `countryRegion` to reduce ambiguity.
1011-
* Limit results with top when only the best match is needed.
1019+
The [Get Geocoding] API is intentionally tolerant of partial and incomplete addresses and minor typos. This flexibility can produce technically valid matches that aren't appropriate for "submit to search" experiences where users expect a precise match or no results.
10121020

1013-
### Forward geocoding example request
1021+
This section describes practical techniques to reduce low‑quality matches for Search by combining signals returned by Get Geocoding:
1022+
1023+
* Confidence (High, Medium, Low). For more information, see [ConfidenceEnum].
1024+
* Match codes (Good, Ambiguous, UpHierarchy). For more information, see [MatchCodesEnum].
1025+
* Result type (properties.type — for example: Address, PopulatedPlace, RoadBlock, AdminDivision1). For more information, see [properties.type].
1026+
1027+
> [!NOTE]
1028+
> `RoadBlock` is formally listed as a possible [properties.type] value and is also referenced in [match‑code][MatchCodesEnum] documentation as an example of an `UpHierarchy` fallback. Treat it as a signal that the service could not resolve the query to a more specific street‑level address.
1029+
1030+
#### Prefer structured parameters when you know the address components
1031+
1032+
If your application collects address parts (street, city, postal code, country/region), use structured `address` parameters instead of a single free‑form `query` parameter. This typically produces more accurate results than query‑only searches.
1033+
1034+
##### Structured request example (complete address known)
10141035

10151036
```rest
10161037
GET https://atlas.microsoft.com/geocode
10171038
?api-version=2026-01-01
1018-
&query=1%20Microsoft%20Way%2C%20Redmond%20WA
1039+
&addressLine=1%20Microsoft%20Way
1040+
&locality=Redmond
1041+
&postalCode=98052
10191042
&countryRegion=US
10201043
&top=1
10211044
&subscription-key={Your-Azure-Maps-Key}
10221045
```
10231046

1047+
> [!IMPORTANT]
1048+
> When you use the `query` parameter, only a subset of parameters are valid (for example, bbox, location, view, top). Passing structured fields (such as locality) alongside `query` can cause a conflicting‑parameters error.
1049+
1050+
#### Add location context to geo-bias query-based searches
1051+
1052+
When you must use the `query` parameter, add geographic context to guide results toward the expected area. For example, specify a bounding box (bbox) using the [lon1,lat1,lon2,lat2] format.
1053+
1054+
##### Query-based request example (customer scenario) with bounding box bias
1055+
1056+
```rest
1057+
GET https://atlas.microsoft.com/geocode
1058+
?api-version=2026-01-01
1059+
&query=1%20Microsoft%20Way
1060+
&bbox=-122.35,47.45,-121.90,47.85
1061+
&top=5
1062+
&subscription-key={Your-Azure-Maps-Key}
1063+
```
1064+
1065+
This reduces the likelihood of low-confidence matches in unrelated regions when the input is loosely structured.
1066+
1067+
#### Filter using confidence + match codes + result type (recommended)
1068+
1069+
[Get Geocoding] returns multiple signals under features[].properties, including `confidence`, `matchCodes`, and `type`. Use these together rather than filtering by `confidence` alone.
1070+
1071+
##### Why confidence alone is not sufficient
1072+
1073+
* **Medium** confidence can indicate a valid result when the query is ambiguous and there isn't enough context to rank one candidate over another.
1074+
1075+
* **Medium** confidence can also occur when the service returns a less precise match than requested, and sets the match code to UpHierarchy (for example, matching only a postal code when an address was requested).
1076+
1077+
##### Reworded clarity: how "up-hierarchy" results happen
1078+
1079+
When the service cannot find a match at the specificity implied by the query, it may "move up the geographic hierarchy" and return a broader location (for example, city, administrative division, or country/region). In those cases, matchCodes includes UpHierarchy, and properties.type indicates what level was actually returned.
1080+
1081+
##### Practical filtering guidance (apply in this order)
1082+
1083+
1. **Reject low-quality matches for exact-search UX**
1084+
If `confidence` is Low, treat the result as not acceptable for an exact-match workflow.
1085+
1. **Detect up-hierarchy fallbacks**
1086+
If `matchCodes` includes `UpHierarchy`, the service could not match the requested granularity and returned a broader location. Use `type` to determine what level was returned (for example, `PopulatedPlace`, `AdminDivision1`, `CountryRegion`, or `RoadBlock`).
1087+
1. **Validate the expected result type**
1088+
If your UX expects a street-level match, accept results only when type is sufficiently specific (for example, Address) and reject broader types (for example, `PopulatedPlace`). This prevents accepting a city/state fallback when the user intended a specific address.
1089+
1. **Handle ambiguity explicitly**
1090+
If `matchCodes` includes `Ambiguous`, the candidates may still be valid. Consider returning multiple candidates or prompting for more detail (postal code, city, or a constrained search area).
1091+
1092+
> [!TIP]
1093+
> Use [properties.type] to understand what was returned and [matchCodes][MatchCodesEnum] to understand how it was derived (for example, `UpHierarchy` fallback).
1094+
10241095
## Best practices for autocomplete
10251096

10261097
Use [Get Geocode Autocomplete] for interactive user input scenarios.
@@ -1166,3 +1237,6 @@ GET https://atlas.microsoft.com/polygon
11661237
[Get Geocoding Batch]: /rest/api/maps/search/get-geocoding-batch
11671238
[Get Reverse Geocoding Batch]: /rest/api/maps/search/get-reverse-geocoding-batch
11681239
[Get Polygon]: /rest/api/maps/search/get-polygon
1240+
[ConfidenceEnum]: /rest/api/maps/search/get-geocoding#confidenceenum
1241+
[MatchCodesEnum]: /rest/api/maps/search/get-geocoding#MatchCodesEnum
1242+
[properties.type]: /rest/api/maps/search/get-geocoding#properties

0 commit comments

Comments
 (0)