結果を特定のタイプに絞り込む
このチュートリアルでは、/autocomplete
エンドポイントのオプションのパラメータ タイプについて説明します。このパラメータタイプを使用すると、結果を特定のタイプに絞り込みます。 結果タイプを使用すると、次のオプションに基づいて特定の結果を取得できます。
プロシージャ
/autocomplete
エンドポイントにはオプションのパラメータtypes
があり 、結果を特定のタイプに限定できます。
次の一覧に、/autocomplete
エンドポイントでサポートされている結果タイプフィルタの値を示します。
-
city
- 結果を resultType
:locality
および localityType
: city
に絞り込む postalCode
- 結果を resultType
: locality
および localityType
: postalCode
に絞り込む。結果タイプフィルタ postalCode
は、ドイツなどの通常の郵便番号、または米国の郵便番号のみをカバーします。 「高精度」郵便番号 (英国または米国の郵便番号、ZIP+4 拡張子を持つ郵便番号など) には resultType
: postalCodePoint
があり、 postalCode
結果タイプのフィルターには含まれません。 area
- すべてのサブタイプを含む結果タイプ 。locality
または administrativeArea
に結果を絞り込みます
例として、国をDEU
に限定したクエリAlexand
を使用してみましょう。 結果タイプの制約がない場合、/autocomplete
エンドポイントは 、street
およびlocality
を含むさまざまなタイプの結果を返します 。
GET https://autocomplete.search.hereapi.com/v1/
autocomplete
?q=Alexand
&in=countryCode%3ADEU
&limit=2
&apiKey={YOUR_API_KEY}
次のパラメータが使用されます。
- Q - フリーテキストのクエリを入力します。
- In-地理的領域内で検索します。 結果が指定した領域にある場合は、結果が返されます。
- Limit :返される結果の最大数
- apiKey - お客様の API キー 。
注
この要求は API キー 認証を使用します。 HERE platform の認証オプションの詳細については、『ID およびアクセス管理ガイド』を参照してください。
最初の 2 つの結果は ベルリンでのタイプstreet
です。
{
"items": [
{
"title": "Deutschland, Berlin, Alexanderstraße",
"id": "here:af:street:nJn6GSK6GnY2ogUvJEbxgC",
"language": "de",
"resultType": "street",
"address": {
"label": "Alexanderstraße, 10178 Berlin, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "BE",
"state": "Berlin",
"countyCode": "B",
"county": "Berlin",
"city": "Berlin",
"district": "Mitte",
"street": "Alexanderstraße",
"postalCode": "10178"
},
"highlights": {
"title": [
{
"start": 21,
"end": 28
}
],
"address": {
"label": [
{
"start": 0,
"end": 7
}
],
"street": [
{
"start": 0,
"end": 7
}
]
}
}
},
{
"title": "Deutschland, Berlin, Tunnel Alexanderplatz",
"id": "here:af:street:8D.iFHvj6zgTiCN1V583EC",
"language": "de",
"resultType": "street",
"address": {
"label": "Tunnel Alexanderplatz, 10178 Berlin, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "BE",
"state": "Berlin",
"countyCode": "B",
"county": "Berlin",
"city": "Berlin",
"district": "Mitte",
"street": "Tunnel Alexanderplatz",
"postalCode": "10178"
},
"highlights": {
"title": [
{
"start": 28,
"end": 35
}
],
"address": {
"label": [
{
"start": 7,
"end": 14
}
],
"street": [
{
"start": 7,
"end": 14
}
]
}
}
}
]
}
エンド ユーザーが番地または番地の結果に関心がない場合、顧客アプリケーションは結果タイプarea
を次のように絞り込みます。
GET https://autocomplete.search.hereapi.com/v1/
autocomplete
?q=Alexand
&in=countryCode%3ADEU
&limit=2
&types=area
&apiKey={YOUR_API_KEY}
1 つ目の結果はオルデンブルクの街で、 2 つ目の結果はババリアの小さな街です。
{
"items": [
{
"title": "Deutschland, 26127, Oldenburg (Oldb.), Alexandersfeld",
"id": "here:cm:namedplace:20155909",
"language": "de",
"resultType": "locality",
"localityType": "district",
"address": {
"label": "Alexandersfeld, Oldenburg (Oldb.), Niedersachsen, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "NI",
"state": "Niedersachsen",
"countyCode": "OL",
"county": "Oldenburg (Oldb.)",
"city": "Oldenburg (Oldb.)",
"district": "Alexandersfeld",
"postalCode": "26127"
},
"highlights": {
"title": [
{
"start": 39,
"end": 46
}
],
"address": {
"label": [
{
"start": 0,
"end": 7
}
],
"district": [
{
"start": 0,
"end": 7
}
]
}
}
},
{
"title": "Deutschland, 95680, Bad Alexandersbad",
"id": "here:cm:namedplace:20182868",
"language": "de",
"resultType": "locality",
"localityType": "city",
"address": {
"label": "Bad Alexandersbad, Bayern, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "BY",
"state": "Bayern",
"countyCode": "WUN",
"county": "Wunsiedel im Fichtelgebirge",
"city": "Bad Alexandersbad",
"postalCode": "95680"
},
"highlights": {
"title": [
{
"start": 24,
"end": 31
}
],
"address": {
"label": [
{
"start": 4,
"end": 11
}
],
"city": [
{
"start": 4,
"end": 11
}
]
}
}
}
]
}
エンド ユーザーが都市または町のみを検索している場合、顧客アプリケーションは結果タイプcity
を 次の代わりにarea
のみに絞り込めます。
GET https://autocomplete.search.hereapi.com/v1/
autocomplete
?q=Alexand
&in=countryCode%3ADEU
&limit=2
&types=city
&apiKey={YOUR_API_KEY}
/autocomplete
このエンドポイントは、現在ババリアの小さな町のみを返します。
{
"items": [
{
"title": "Deutschland, 95680, Bad Alexandersbad",
"id": "here:cm:namedplace:20182868",
"language": "de",
"resultType": "locality",
"localityType": "city",
"address": {
"label": "Bad Alexandersbad, Bayern, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "BY",
"state": "Bayern",
"countyCode": "WUN",
"county": "Wunsiedel im Fichtelgebirge",
"city": "Bad Alexandersbad",
"postalCode": "95680"
},
"highlights": {
"title": [
{
"start": 24,
"end": 31
}
],
"address": {
"label": [
{
"start": 4,
"end": 11
}
],
"city": [
{
"start": 4,
"end": 11
}
]
}
}
}
]
}
types=postalCode
では、/autocomplete
エンドポイントは完全な郵便番号または一部の郵便番号を入力として想定しています。 Alexand
を使用したクエリ types=postalCode
では、結果は返されません。
/autocomplete
パラメータの詳細については、次のトピックを参照してください。 API リファレンス。
さまざまなエンドポイントによるtypes
フィルタサポートの概要については、次の点を確認してください。 結果をタイプでフィルタリングします。