不完全なカテゴリのクエリを使用して、placeの候補を取得
このチュートリアルでは、不完全なカテゴリのクエリを使用して場所を検索する方法について説明します。
プロシージャ
埋め込まれたアプリケーション ( 車または携帯電話 ) を使用してレストランを検索しているユーザーが、「レストラン」というテキストの入力を開始します。 アプリケーションは /autosuggest
、 3 番目のキーストロークからクエリを送信します。 ベルリンのどこかで「 res 」の部分的な問い合わせを提案する場合、その問い合わせは次のように表示されます。
GET https://autosuggest.search.hereapi.com/v1/
autosuggest
?at=52.93175,12.77165
&limit=5
&lang=en
&q=res
&apiKey={YOUR_API_KEY}
次のパラメータが使用されます。
- at - 座標で表された検索コンテキストの中心を指定
- Limit :返される結果の最大数
- lang- BCP 47 に準拠した言語コードのリストから、結果のレンダリングに使用する言語を選択
- Q - フリーテキストのクエリを入力します。
- apiKey - お客様の API キー 。
注
この要求は API キー 認証を使用します。 HERE platform の認証オプションの詳細については、『ID およびアクセス管理ガイド』を参照してください。
上記のリクエストに対する応答は、次のように表示されます。
{
"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": [ ]
}
Autosuggestエンジンは、ユーザーがクエリの候補を選択した場合に使用するアプリケーションのフォローアップ URI とともに、カテゴリの提案「 Restaurants 」を返します。 このフォローアップの問い合わせでは、同じユーザーの場所にあるレストランの場所が返されます。
さらに、提案エンジンが関連する一連のレストランを返します。
/autosuggest
パラメータの詳細については、次のトピックを参照してください。 API リファレンス。