Formulate a hybrid query
This tutorial demonstrates how to use hybrid queries.
Procedure
Qualified and free form input can be combined. This can be helpful, for instance, when the end-user inputs the free-form text into a single search box while the application provides the structured elements in the background for local focus.
Another example, when the application provides to the end-user an input box for a free-form address text and e.g. a drop-down box for postal codes.
The address query 141 Boulevard Émile Thomas
with postal code set to 83300
can be formulated with the following:
GET https://geocode.search.hereapi.com/v1/
geocode
?q=141+Boulevard+Émile+Thomas
&qq=
postalCode=83300
&apiKey={YOUR_API_KEY}
The following parameters are used:
- q - Enter a free-text query.
- qq - Enter a qualified query. A qualified query is similar to a free-text query, but in a structured manner. It can take multiple sub-parameters, separated by semicolon, allowing to specify different aspects of a 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 looks like the following:
{
"items": [
{
"title": "141 Boulevard Émile Thomas, 83300 Draguignan, France",
"id": "here:af:streetsection:hqlRKFTx4wa5F6e9DhA2HA:CggIBCCd0YiOAxABGgMxNDEoZA",
"resultType": "houseNumber",
"houseNumberType": "PA",
"address": {
"label": "141 Boulevard Émile Thomas, 83300 Draguignan, France",
"countryCode": "FRA",
"countryName": "France",
"stateCode": "PAC",
"state": "Provence-Alpes-Côte d'Azur",
"county": "Var",
"city": "Draguignan",
"street": "Boulevard Émile Thomas",
"postalCode": "83300",
"houseNumber": "141"
},
"position": {
"lat": 43.52944,
"lng": 6.47991
},
"access": [
{
"lat": 43.52938,
"lng": 6.48023
}
],
"mapView": {
"west": 6.47867,
"south": 43.52854,
"east": 6.48115,
"north": 43.53034
},
"scoring": {
"queryScore": 1,
"fieldScore": {
"streets": [
1
],
"houseNumber": 1,
"postalCode": 1
}
}
}
]
}
Additional information
For more information about/geocode
parameters, see: API Reference.