如何使用特定语言进行搜索 - Amazon Location Service

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

如何使用特定语言进行搜索

此功能允许从 BCP47兼容代码中选择首选响应语言。它根据名称变体检测查询语言,并使用首选语言处理不匹配的标记和模棱两可的情况。如果没有请求的语言,Plac es API 会以官方国家/地区语言提供搜索结果,但会优先考虑不同区域语言的区域。作为后备策略,如果请求的语言中没有任何地址元素不可用,Plac es 将以默认语言 APIs 返回地址。

潜在用例

一个潜在的用例是本地化查询和/或结果。

示例

如果请求中没有该"Language": "EN"行,结果将以希伯来语返回。

Sample request
{ "QueryText": "Vegan", "BiasPosition":[ 34.78953, 32.08556 ], "Language": "EN" }
Sample response
{ "ResultItems": [ { "PlaceId": "<Redacted>", "PlaceType": "PointOfInterest", "Title": "Rainbow", "Address": { "Label": "Rainbow, Ibn Gabirol 88, 6404612 Tel Aviv-Yafo, Israel", "Country": { "Code2": "IL", "Code3": "ISR", "Name": "Israel" }, "Region": { "Code": "TA", "Name": "TA" }, "SubRegion": { "Name": "Tel Aviv" }, "Locality": "Tel Aviv-Yafo", "District": "The New North-Southern Area", "PostalCode": "6404612", "Street": "Ibn Gabirol", "StreetComponents": [ { "BaseName": "Ibn Gabirol", "Language": "he-Latn" } ], "AddressNumber": "88" }, "Position": [ 34.78149, 32.08252 ], "Distance": 829, "Categories": [ { "Id": "restaurant", "Name": "Restaurant", "LocalizedName": "Restaurant", "Primary": true }, { "Id": "fast_food", "Name": "Fast Food", "LocalizedName": "Fast Food", "Primary": false } ], "FoodTypes": [ { "LocalizedName": "Vegan", "Id": "vegan", "Primary": true }, { "LocalizedName": "Fast Food", "Id": "fast_food", "Primary": false }, { "LocalizedName": "Burgers", "Id": "burgers", "Primary": false }, { "LocalizedName": "Jewish/Kosher", "Id": "jewish/kosher", "Primary": false } ] }, { "PlaceId": "<Redacted>", "PlaceType": "PointOfInterest", "Title": "Alegria", "Address": { "Label": "Alegria, Ibn Gabirol 165, 6203305 Tel Aviv-Yafo, Israel", "Country": { "Code2": "IL", "Code3": "ISR", "Name": "Israel" }, "Region": { "Code": "TA", "Name": "TA" }, "SubRegion": { "Name": "Tel Aviv" }, "Locality": "Tel Aviv-Yafo", "District": "The Old North-Northern Area", "PostalCode": "6203305", "Street": "Ibn Gabirol", "StreetComponents": [ { "BaseName": "Ibn Gabirol", "Language": "he-Latn" } ], "AddressNumber": "165" }, "Position": [ 34.78295, 32.0923 ], "Distance": 973, "Categories": [ { "Id": "restaurant", "Name": "Restaurant", "LocalizedName": "Restaurant", "Primary": true }, { "Id": "coffee_shop", "Name": "Coffee Shop", "LocalizedName": "Coffee Shop", "Primary": false }, { "Id": "specialty_food_store", "Name": "Specialty Food Store", "LocalizedName": "Specialty Food Store", "Primary": false }, { "Id": "bakery_and_baked_goods_store", "Name": "Bakery and Baked Goods Store", "LocalizedName": "Bakery & Baked Goods Store", "Primary": false } ], "FoodTypes": [ { "LocalizedName": "Vegan", "Id": "vegan", "Primary": true } ] } ] }
cURL
curl --request POST \ --url 'https://places.geo.eu-central-1.amazonaws.com/v2/search-text?key=Your_Key' \ --header 'Content-Type: application/json' \ --data ' { "QueryText": "Vegan", "BiasPosition":[ 34.78953, 32.08556 ], "Language": "EN" }'
AWS CLI
aws geo-places search-text --key ${YourKey} --query-text "Vegan" \ --bias-position 34.78953 32.08556 \ --language "EN"