

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

# 如何使用篩選條件完成地址
<a name="how-to-complete-address-with-filters"></a>

Autocomplete API 可讓您完成部分輸入的地址，為最終使用者提供快速且標準化的地址輸入。透過使用 `AdditionalFeatures` 參數，您可以自訂回應中提供的資訊，以符合特定需求。

## 潛在的使用案例
<a name="potential-use"></a>
+ **將資料降至最低以降低成本：**當預期後續查詢時，透過僅請求基本地址元件來降低回應大小和資料傳輸成本。
+ **包含直接使用的必要詳細資訊：**擷取完整的地址資訊，以消除其他查詢的需求。

## 範例
<a name="autocomplete-address-examples"></a>

### 使用國家/地區篩選條件完成地址
<a name="autocomplete-country-filter"></a>

此範例會套用國家/地區篩選條件來精簡結果，讓標準化形式的使用者輸入地址能夠準確填入表單欄位。

------
#### [ Sample request ]

```
{
  "QueryText": "100 McCullum Rd",
  "Filter": {
    "IncludeCountries": [
      "GBR"
    ]
  }
}
```

------
#### [ Sample response ]

```
{
    "ResultItems": [
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "PointAddress",
            "Title": "United Kingdom, E3 5JB, London, 100 McCullum Road",
            "Address": {
                "Label": "100 McCullum Road, London, E3 5JB, United Kingdom",
                "Country": {
                    "Code2": "GB",
                    "Code3": "GBR",
                    "Name": "United Kingdom"
                },
                "Region": {
                    "Name": "England"
                },
                "SubRegion": {
                    "Code": "LDN",
                    "Name": "London"
                },
                "Locality": "London",
                "District": "Bow",
                "PostalCode": "E3 5JB",
                "Street": "McCullum Road",
                "StreetComponents": [
                    {
                        "BaseName": "McCullum",
                        "Type": "Road",
                        "TypePlacement": "AfterBaseName",
                        "TypeSeparator": " ",
                        "Language": "en"
                    }
                ],
                "AddressNumber": "100"
            },
            "Language": "en",
            "Highlights": {
                "Title": [
                    {
                        "StartIndex": 32,
                        "EndIndex": 35,
                        "Value": "100"
                    },
                    {
                        "StartIndex": 36,
                        "EndIndex": 49,
                        "Value": "McCullum Road"
                    }
                ],
                "Address": {
                    "Label": [
                        {
                            "StartIndex": 0,
                            "EndIndex": 3,
                            "Value": "100"
                        },
                        {
                            "StartIndex": 4,
                            "EndIndex": 17,
                            "Value": "McCullum Road"
                        }
                    ],
                    "Street": [
                        {
                            "StartIndex": 0,
                            "EndIndex": 13,
                            "Value": "McCullum Road"
                        }
                    ],
                    "AddressNumber": [
                        {
                            "StartIndex": 0,
                            "EndIndex": 3,
                            "Value": "100"
                        }
                    ]
                }
            }
        }
    ],
    "QueryRefinements": []
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://places.geo.eu-central-1.amazonaws.com/v2/autocomplete?key=Your_Key' \
  --header 'Content-Type: application/json' \
  --data '{
  "QueryText": "100 McCullum Rd",
  "Filter": {
    "IncludeCountries": [
      "GBR"
    ]
  }
}'
```

------
#### [ AWS CLI ]

```
aws geo-places autocomplete --key ${YourKey} --query-text "100 McCullum Rd" \
--filter '{"IncludeCountries": ["GBR"]}'
```

------

### 使用其他資料完成地址
<a name="autocomplete-additional-data"></a>

此範例會傳回其他資料，允許傳回的地址詳細資訊在沒有後續查詢的情況下使用。額外的功能`Core`集已足夠用於此使用案例。

------
#### [ Sample request ]

```
{
  "QueryText": "100 McCullum Rd",
  "Filter": {
    "IncludeCountries": [
      "GBR"
    ]
  },
  "AdditionalFeatures": [
    "Core"
  ]
}
```

------
#### [ Sample response ]

```
{
    "ResultItems": [
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "PointAddress",
            "Title": "United Kingdom, E3 5JB, London, 100 McCullum Road",
            "Address": {
                "Label": "100 McCullum Road, London, E3 5JB, United Kingdom",
                "Country": {
                    "Code2": "GB",
                    "Code3": "GBR",
                    "Name": "United Kingdom"
                },
                "Region": {
                    "Name": "England"
                },
                "SubRegion": {
                    "Code": "LDN",
                    "Name": "London"
                },
                "Locality": "London",
                "District": "Bow",
                "PostalCode": "E3 5JB",
                "Street": "McCullum Road",
                "StreetComponents": [
                    {
                        "BaseName": "McCullum",
                        "Type": "Road",
                        "TypePlacement": "AfterBaseName",
                        "TypeSeparator": " ",
                        "Language": "en"
                    }
                ],
                "AddressNumber": "100"
            },
            "Language": "en",
            "Highlights": {
                "Title": [
                    {
                        "StartIndex": 32,
                        "EndIndex": 35,
                        "Value": "100"
                    },
                    {
                        "StartIndex": 36,
                        "EndIndex": 49,
                        "Value": "McCullum Road"
                    }
                ],
                "Address": {
                    "Label": [
                        {
                            "StartIndex": 0,
                            "EndIndex": 3,
                            "Value": "100"
                        },
                        {
                            "StartIndex": 4,
                            "EndIndex": 17,
                            "Value": "McCullum Road"
                        }
                    ],
                    "Street": [
                        {
                            "StartIndex": 0,
                            "EndIndex": 13,
                            "Value": "McCullum Road"
                        }
                    ],
                    "AddressNumber": [
                        {
                            "StartIndex": 0,
                            "EndIndex": 3,
                            "Value": "100"
                        }
                    ]
                }
            }
        }
    ],
    "QueryRefinements": []
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://places.geo.eu-central-1.amazonaws.com/v2/autocomplete?key=Your_Key' \
  --header 'Content-Type: application/json' \
  --data '{
  "QueryText": "100 McCullum Rd",
  "Filter": {
    "IncludeCountries": [
      "GBR"
    ]
  },
  "AdditionalFeatures": [
    "Core"
  ]
}'
```

------
#### [ AWS CLI ]

```
aws geo-places autocomplete --key ${YourKey} --query-text "100 McCullum Rd" \
--additional-features "Core" \
--filter '{"IncludeCountries": ["GBR"]}'
```

------