不完全なカテゴリークエリを使用して場所の候補を取得する
このチュートリアルでは、不完全なカテゴリー クエリを使用して場所を検索する方法を説明します。
手順
組み込みの車載またはモバイルアプリケーションを使用してレストランを検索しているユーザーが、
「レストラン」というテキストを入力し始めるとします。アプリケーションは3文字目の入力から/autosuggestエンドポイントへのクエリ送信を
開始します。たとえば、ベルリン周辺で「レスト」という部分クエリの候補を取得する場合、呼び出しは次のようになります。
GET https://autosuggest.search.hereapi.com/v1/
autosuggest
?at=39.31974,-76.56721
&limit=5
&q=rest
&apiKey={YOUR_API_KEY}次のパラメーターを使用します。
- at - 座標で表される検索コンテキストの中心を指定します。
- limit - 返される結果の最大数。
- lang - BCP 47 に準拠した言語コードのリストから、結果のレンダリングに使用する言語を選択します。
- q - 名前を入力します。
- apiKey - APIキー。
注
このリクエストはAPIキー認証を使用します。HEREプラットフォームの認証オプションの詳細については、「Identity & Access Management Guide」(IDとアクセス管理ガイド)を参照してください。
上のリクエストに対するレスポンスは次のようになります。
{
"items": [
{
"title": "Restaurant",
"id": "here:cm:ontology:restaurant",
"resultType": "categoryQuery",
"href": "https://autosuggest.search.hereapi.com/v1/discover?at=39.31974%2C-76.56721&limit=5&q=Restaurant&_ontology=restaurant",
"highlights": { "title": [{ "start": 0, "end": 4 }] }
},
{
"title": "Rest stop",
"id": "here:cm:ontology:rest_area",
"resultType": "categoryQuery",
"href": "https://autosuggest.search.hereapi.com/v1/discover?at=39.31974%2C-76.56721&limit=5&q=Rest+stop&_ontology=rest_area",
"highlights": { "title": [{ "start": 0, "end": 4 }] }
},
{
"title": "Restoration East",
"id": "here:pds:place:840dqcx9-2f1561a4501b4cc0a49aa6611838b448",
"resultType": "place",
"address": { "label": "Restoration East, 4209 E Chase St, Baltimore, MD 21205-3020, United States" },
"position": { "lat": 39.30398, "lng": -76.56193 },
"access": [{ "lat": 39.30435, "lng": -76.56264 }],
"distance": 1810,
"categories": [{ "id": "700-7400-0000", "name": "Consumer Services", "primary": true }, { "id": "700-7200-0277", "name": "Specialty Trade Contractors" }],
"highlights": { "title": [{ "start": 0, "end": 4 }], "address": { "label": [{ "start": 0, "end": 4 }] } }
},
{
"title": "Rent Now (Rest for the Wicke)",
"id": "here:pds:place:8403fv6k-b6fd543c49df01f3ae3981be17ed3412",
"resultType": "place",
"address": { "label": "Rent Now, 5229 Harford Rd, Baltimore, MD 21214-2622, United States" },
"position": { "lat": 39.34978, "lng": -76.56321 },
"access": [{ "lat": 39.34991, "lng": -76.56347 }],
"distance": 3358,
"categories": [{ "id": "700-7400-0145", "name": "Real Estate Services", "primary": true }, { "id": "600-6950-0000", "name": "Hair & Beauty" }, { "id": "700-7400-0000", "name": "Consumer Services" }],
"highlights": { "title": [{ "start": 10, "end": 14 }], "address": { "label": [ ] } }
},
{
"title": "Prorest Pest (Pro Rest Pest)",
"id": "here:pds:place:840dqcxd-2a86850c1c34418f8023280a5f7baf62",
"resultType": "place",
"address": { "label": "Prorest Pest, 6600 Frankford Ave, Baltimore, MD 21206-4901, United States" },
"position": { "lat": 39.31265, "lng": -76.54259 },
"access": [{ "lat": 39.31285, "lng": -76.54273 }],
"distance": 2260,
"categories": [{ "id": "700-7200-0277", "name": "Specialty Trade Contractors", "primary": true }, { "id": "550-5520-0210", "name": "Wildlife Refuge" }, { "id": "700-7400-0000", "name": "Consumer Services" }],
"references": [{ "supplier": { "id": "yelp" }, "id": "BY3MjxFzBwCl_OemyfJBKQ" }],
"highlights": { "title": [{ "start": 3, "end": 7 }, { "start": 18, "end": 22 }], "address": { "label": [{ "start": 3, "end": 7 }] } }
}
],
"queryTerms": [ ]
}AutoSuggestエンジンはカテゴリー候補の「レストラン」と一緒に、 ユーザーがクエリ候補を選択した場合にアプリケーションが使用するフォローアップURIを返します。
このフォローアップ クエリでは、同じユーザー位置にあるレストランの場所が返されます。
また、候補提案エンジンは関連するレストランのセットを返します。
追加情報
/autosuggestエンドポイントパラメーターの詳細については、「APIリファレンス」を参照してください。
4 日前の更新