How to exclude place results

This tutorial demonstrates how to exclude place results from /geocode endpoint result list with help of optional parameter types.

Procedure

The /geocode endpoint has an optional parameter types which allows limiting the results to specific types.

Values of the result type filter, required to exclude place results are:

  • address - restricting results to result types houseNumber, street, postalCodePoint, intersection, or addressBlock.
  • area - restricting results to result types: locality or administrativeArea including all the sub-types.

Other values of types filter, supported by /geocode endpoint are: city, postalCode, street, houseNumber - check the API Reference for more details.

For example, when querying for 'Harfowa, Warszawa', there may be two relevant results: a street named 'ulica Harfowa' and a nearby bus station named 'Harfowa'. Without using the types filter, only the bus station result with a resultType of place would be returned, since it is more precise and matches the query name perfectly.

{
  "items": [
    {
      "title": "Harfowa",
      "id": "here:pds:place:616q9wpy-4be9c9c2e0060d9880fa7e8d8d3fc104",
      "resultType": "place",
      "address": {
        "label": "Harfowa, ulica Włodarzewska, 02-384 Ochota, Polska",
        "countryCode": "POL",
        "countryName": "Polska",
        "state": "Woj. Mazowieckie",
        "county": "Warszawa",
        "city": "Warszawa",
        "district": "Ochota",
        "subdistrict": "Szczęśliwice",
        "street": "ulica Włodarzewska",
        "postalCode": "02-384"
      },
      "position": {
        "lat": 52.2017,
        "lng": 20.96456
      },
      "access": [
        {
          "lat": 52.20162,
          "lng": 20.96435
        }
      ],
      "categories": [
        {
          "id": "400-4100-0042",
          "name": "Przystanek autobusowy",
          "primary": true
        }
      ],
      "scoring": {
        "queryScore": 1,
        "fieldScore": {
          "city": 1,
          "placeName": 1
        }
      }
    }
  ]
}

With help of parameter types=address,area the customer application may exclude place results:

GET https://geocode.search.hereapi.com/v1/
    geocode
    ?q=Harfowa%2C+Warszawa
    &types=address%2Carea
    &apiKey={YOUR_API_KEY}

The following parameters are used:

  • q - Enter a free-text query.
  • types - A comma-separated list of the types that should be included in the response.
  • apiKey - Your API key.

Note

This request uses API key authentication. For more information about authentication options on the HERE platform, see the Identity & Access Management Guide.

The response to the above request will not anymore be the bus station, but a fuzzy match to street ulica Harfowa:

{
  "items": [
    {
      "title": "ulica Harfowa, 02-389 Ochota, Polska",
      "id": "here:af:streetsection:RZk.ZvMCIgkrPBiscT2oGB",
      "resultType": "street",
      "address": {
        "label": "ulica Harfowa, 02-389 Ochota, Polska",
        "countryCode": "POL",
        "countryName": "Polska",
        "state": "Woj. Mazowieckie",
        "county": "Warszawa",
        "city": "Warszawa",
        "district": "Ochota",
        "subdistrict": "Szczęśliwice",
        "street": "ulica Harfowa",
        "postalCode": "02-389"
      },
      "position": {
        "lat": 52.20009,
        "lng": 20.96503
      },
      "mapView": {
        "west": 20.96401,
        "south": 52.19966,
        "east": 20.96639,
        "north": 52.20156
      },
      "scoring": {
        "queryScore": 1,
        "fieldScore": {
          "city": 1,
          "streets": [
            0.9
          ]
        }
      }
    }
  ]
}

Additional information

For more information about/geocode parameters, see: API Reference.

For an overview of types filter support by different endpoints check: Filtering results by their types.

results matching ""

    No results matching ""