How do you perform an exact string match using GS API v7?

Viewed 85

I need to be able to look up a location based on an exact city, state, and country triplet.

HERE's Geocoder v6.2 API supports exact matching out of the box, however that API is in maintenance mode and I would prefer to be on the latest and greatest given I'm starting a project from scratch.

Here's some examples: You can hit the Geocoder v6.2 API with a request including a fake city and get the correct response (no results):

https://geocoder.ls.hereapi.com/6.2/geocode.json?apiKey=...&country=USA&state=TX&city=Faketown

{
  "Response": {
    "MetaInfo": {
      "Timestamp": "2021-02-12T01:53:40.367+0000"
    },
    "View": []
  }
}

but what I believe is an equivalent request to the GS v7.0 API returns incorrect results when using the "qualified query" syntax:

https://geocode.search.hereapi.com/v1/geocode?apiKey=...&qq=country=USA;state=TX;city=Faketown

{
  "items": [
    {
      "title": "Laketown, UT, United States",
      "id": "here:cm:namedplace:21035617",
      "resultType": "locality",

(Wrong city, wrong state, correct country).

What do you need to do to get the v7 API (geocode or otherwise) to use exact matching and thus return zero results for this request? Or should I use the Geocoder v6.2 API for this instead?

1 Answers

Geocoder v7 API Documentation states the following information.

The /geocode endpoint is used to find the geo-coordinates of a known address, place, locality or administrative area, even if the query is incomplete or partly incorrect. It also returns a complete postal address string and address details.

This is the reason behind the behavior, you can check the following link for more information.

https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics/endpoint-geocode-brief.html

We can recommend you to opt for /Autocomplete which provides completion of the entered keystrokes to the valid addresses, where no spell correction is included.

For more information you can check the following link.

https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics-api/code-autocomplete-examples.html

For hands on experience you can also check the following link. https://tcs.ext.here.com/examples/v3/admin_boundaries_batch

Related