Get suggestions for a place using an incomplete category query

This tutorial demonstrates how to search for a place using an incomplete category query.

Procedure

A user searching for restaurants using an embedded application (in his car or on his cellphone) starts entering the text "restaurant." The application submits /autosuggest queries starting with the 3rd key stroke. For suggestions to a "res" partial query somewhere in Berlin, the call would aappear as follows:

GET https://autosuggest.search.hereapi.com/v1/
    autosuggest
    ?at=52.93175,12.77165
    &limit=5
    &lang=en
    &q=res
    &apiKey={YOUR_API_KEY}

The following parameters are used:

  • at - Specify the center of the search context expressed as coordinates.
  • limit - Maximum number of results to be returned.
  • lang - Select the language to be used for result rendering from a list of BCP 47 compliant language codes.
  • q - Enter a free-text query.
  • 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 appears as follows:

{
  "items": [
    {
      "title": "restaurant",
      "id": "here:cm:ontology:restaurant",
      "resultType": "categoryQuery",
      "href": "https://autosuggest.search.hereapi.com/v1/discover?q=restaurant&_ontology=restaurant&lang=en&at=52.93175%2C12.77165",
      "highlights": { "title": [{ "start": 0, "end": 3 }] }
    },
    {
      "title": "Resort Mark Brandenburg",
      "id": "here:pds:place:276u33j5-6ad49082b9ed4e7bbb88c011d7e8babe",
      "resultType": "place",
      "address": { "label": "Resort Mark Brandenburg, An der Seepromenade 20, 16816 Neuruppin, Germany" },
      "position": { "lat": 52.924, "lng": 12.81321 },
      "access": [{ "lat": 52.9241, "lng": 12.81307 }],
      "distance": 2916,
      "categories": [
        { "id": "500-5000-0000", "name": "Hotel/Motel", "primary": true },
        { "id": "500-5000-0053", "name": "Hotel" },
        { "id": "500-5100-0000", "name": "Lodging" },
        { "id": "500-5100-0059", "name": "Holiday Park" }
      ],
      "chains": [{ "id": "2106" }],
      "references": [ ... ],
      "highlights": { "title": [{ "start": 0, "end": 3 }], "address": { "label": [{ "start": 0, "end": 3 }] } }
    },
    {
      "title": "Hotel & Restaurant am Alten Rhin",
      "id": "here:pds:place:276u33jh-81e655b8ed9246209bcf978fdbcb7db5",
      "resultType": "place",
      "address": { "label": "Hotel & Restaurant am Alten Rhin, Friedrich-Engels-Straße 12, 16827 Neuruppin, Germany" },
      "position": { "lat": 52.95022, "lng": 12.84247 },
      "access": [{ "lat": 52.95026, "lng": 12.84258 }],
      "distance": 5171,
      "categories": [
        { "id": "500-5000-0053", "name": "Hotel", "primary": true },
        ...
      ],
      "references": [ ... ],
      "foodTypes": [ ... ],
      "highlights": { "title": [ ], "address": { "label": [ ] } }
    },
    {
      "title": "Restaurant Rosengarten",
      "id": "here:pds:place:276u33j5-9684ac8171c0408bb0f787b37599548b",
      "resultType": "place",
      "address": { "label": "Restaurant Rosengarten, Wichmannstraße 8, 16816 Neuruppin, Germany" },
      "position": { "lat": 52.92393, "lng": 12.80519 },
      "access": [{ "lat": 52.924, "lng": 12.8053 }],
      "distance": 2411,
      "categories": [
        { "id": "100-1000-0000", "name": "Restaurant", "primary": true },
        ...
      ],
      "references": [ ... ],
      "foodTypes": [ ... ],
      "highlights": { "title": [{ "start": 0, "end": 3 }], "address": { "label": [{ "start": 0, "end": 3 }] } }
    },
    {
      "title": "Restaurant Seegarten",
      "id": "here:pds:place:276u33j5-49777259a2fe4c76a37f8387ca702a6a",
      "resultType": "place",
      "address": { "label": "Restaurant Seegarten, Regattastraße 17, 16816 Neuruppin, Germany" },
      "position": { "lat": 52.91976, "lng": 12.80827 },
      "access": [{ "lat": 52.91978, "lng": 12.80808 }],
      "distance": 2793,
      "categories": [{ "id": "100-1000-0000", "name": "Restaurant", "primary": true }],
      "references": [ ... ],
      "foodTypes": [ ... ],
      "highlights": { "title": [{ "start": 0, "end": 3 }], "address": { "label": [{ "start": 0, "end": 3 }] } }
    }
  ],
  "queryTerms": [ ]
}

The Autosuggest engine returns the category suggestion "Restaurants", along with a follow-up URI for the application to use if the user chooses the query suggestion. This follow-up query will return restaurant places at the same user location.

Additionally, the suggestion engine returns a set of relevant restaurants.

Additional information

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

results matching ""

    No results matching ""