如何取得部分輸入或拼寫錯誤查詢的結果 - Amazon Location Service

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

如何取得部分輸入或拼寫錯誤查詢的結果

建議 API 可讓應用程式完成結果位置或類別的使用者查詢。這些結果從最有可能到不太可能相符的項目排序,允許 API 解決不完整或拼寫錯誤的單字。

潛在的使用案例

  • 完成部分輸入的興趣點查詢:根據部分輸入或不正確的項目提供建議,協助使用者。

範例

Sample request
{ "QueryText": "Effel tow", "Filter": { "Circle": { "Radius": 10000, "Center": [2.3431932014695382, 48.858844492141145] }, "IncludeCountries": ["FRA"] }, "AdditionalFeatures": ["Core"] }
Sample response
{ "ResultItems": [ { "Title": "Tour Eiffel (Eiffel Tower)", "SuggestResultItemType": "Place", "Place": { "PlaceId": "<Redacted>", "PlaceType": "PointOfInterest", "Address": { "Label": "Tour Eiffel, 5 Avenue Anatole France, 75007 Paris, France", "Country": {"Code2": "FR", "Code3": "FRA", "Name": "France"}, "Region": {"Code": "IDF", "Name": "Île-de-France"}, "SubRegion": {"Name": "Paris"}, "Locality": "Paris", "District": "7e Arrondissement", "PostalCode": "75007", "Street": "Avenue Anatole France", "StreetComponents": [{"BaseName": "Anatole France", "Type": "Avenue", "Language": "fr"}], "AddressNumber": "5" }, "Position": [2.2945, 48.85824], "Distance": 3563, "Categories": [ {"Id": "historical_monument", "Name": "Historical Monument", "LocalizedName": "Monument historique", "Primary": true}, {"Id": "landmark-attraction", "Name": "Landmark-Attraction", "LocalizedName": "Lieu d'intérêt/Attraction", "Primary": false}, {"Id": "tourist_attraction", "Name": "Tourist Attraction", "LocalizedName": "Attraction touristique", "Primary": false}, {"Id": "sports_complex-stadium", "Name": "Sports Complex-Stadium", "LocalizedName": "Stade ou complexe sportif", "Primary": false} ] }, "Highlights": {"Title": [{"StartIndex": 13, "EndIndex": 23, "Value": "Eiffel Tow"}]} } ], "QueryRefinements": [] }
cURL
curl --request POST \ --url 'https://places.geo.eu-central-1.amazonaws.com/v2/suggest?key=Your_Key' \ --header 'Content-Type: application/json' \ --data '{ "QueryText": "Effel tow", "Filter": { "Circle": {"Radius": 10000, "Center": [2.3431932014695382, 48.858844492141145]}, "IncludeCountries": ["FRA"] }, "AdditionalFeatures": ["Core"] }'
AWS CLI
aws geo-places suggest --key ${YourKey} \ --query-text "Effel tow" \ --filter '{"Circle": {"Radius": 1000, "Center": [2.3431932014695382, 48.858844492141145]}, "IncludeCountries": ["FRA"]}' \ --additional-features "Core"

開發人員秘訣

使用篩選條件,例如 Filter.IncludeCountriesFilter.BoundingBox搭配 BiasPosition。這些篩選條件有助於縮小可能的結果,並改善準確性。

{ "QueryText": "Effel tow", "BiasPosition": [2.2982750966095398, 48.856078089325294], "Filter": {"IncludeCountries": ["FRA"]} }