

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Suggest と、リージョンまたは国をフィルタリングする機能を使用する
<a name="suggest-filter-region-country"></a>

Suggest API を使用すると、結果の場所またはカテゴリのクエリを完了できます。結果は、一致する可能性が高い方から低い方にソートされます。さらに、結果を特定のリージョンまたは国に絞り込むこともできます。

## 想定されるユースケース
<a name="suggest-filter-region-country-potential-use"></a>
+ **結果をフィルタリングする: **検索を実行するときに、国またはビジネスが運営されているリージョンでのみフィルタリングできます。

## 例
<a name="suggest-filter-region-country-examples"></a>

国別にフィルターを追加すると、最も関連性の高い結果のみが得られます。これには Filter.IncludeCountries を使用します。

### ユーザーが国別にフィルタリングできるようにする
<a name="suggest-filter-region-country-examples"></a>

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

```
{
  "QueryText": "hote",
  "BiasPosition": [
    2.2982750966095398, 48.856078089325294
  ],
  "Filter": {
    "IncludeCountries": [
      "FRA"
    ]
  },
  "AdditionalFeatures": [
    "Core"
  ]
}
```

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

```
{
    "ResultItems": [
        {
            "Title": "Hôtel de Matignon (Hôtel Matignon)",
            "SuggestResultItemType": "Place",
            "Place": {
                "PlaceId": "Redacted",
                "PlaceType": "PointOfInterest",
                "Address": {
                    "Label": "Hôtel de Matignon, 57 Rue de Varenne, 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": "Rue de Varenne",
                    "StreetComponents": [
                        {
                            "BaseName": "Varenne",
                            "Type": "Rue de",
                            "TypePlacement": "BeforeBaseName",
                            "TypeSeparator": " ",
                            "Language": "fr"
                        }
                    ],
                    "AddressNumber": "57"
                },
                "Position": [
                    2.32072,
                    48.85471
                ],
                "Distance": 1650,
                "Categories": [
                    {
                        "Id": "tourist_attraction",
                        "Name": "Tourist Attraction",
                        "LocalizedName": "Attraction touristique",
                        "Primary": true
                    },
                    {
                        "Id": "landmark-attraction",
                        "Name": "Landmark-Attraction",
                        "LocalizedName": "Lieu d'intérêt/Attraction",
                        "Primary": false
                    },
                    {
                        "Id": "historical_monument",
                        "Name": "Historical Monument",
                        "LocalizedName": "Monument historique",
                        "Primary": false
                    },
                    {
                        "Id": "residential_area-building",
                        "Name": "Residential Area-Building",
                        "LocalizedName": "Bâtiment résidentiel",
                        "Primary": false
                    }
                ]
            },
            "Highlights": {
                "Title": [
                    {
                        "StartIndex": 0,
                        "EndIndex": 4,
                        "Value": "Hôt"
                    },
                    {
                        "StartIndex": 19,
                        "EndIndex": 23,
                        "Value": "(Hô"
                    }
                ],
                "Address": {
                    "Label": [
                        {
                            "StartIndex": 0,
                            "EndIndex": 4,
                            "Value": "Hôt"
                        }
                    ]
                }
            }
        },
        ...
        {
            "Title": "Hotel",
            "SuggestResultItemType": "Query",
            "Query": {
                "QueryId": "Redacted",
                "QueryType": "Category"
            },
            "Highlights": {
                "Title": [
                    {
                        "StartIndex": 0,
                        "EndIndex": 4,
                        "Value": "Hote"
                    }
                ]
            }
        },
        ...
    ],
    "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": "hote",
  "BiasPosition": [
    2.2982750966095398, 48.856078089325294
  ],
  "Filter": {
    "IncludeCountries": [
      "FRA"
    ]
  },
  "AdditionalFeatures": [
    "Core"
  ]
}'
```

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

```
aws geo-places suggest --key ${YourKey} \
--query-text "hote" \
--bias-position 2.2982750966095398 48.856078089325294 \
--filter '{"IncludeCountries": ["FRA"]}' \
--additional-features "Core"
```

------

検索に filter-by-region オプションを追加すると、結果は指定されたリージョンに収まるもののみに制限されます。これは、検索の範囲をビジネスに関連するリージョンに制限するために使用されます。次の例は、ボストンエリアの近くにある Marriott ホテルの検索にスペルミスがあり、何件かのホテルの結果とフォローアップクエリでの完了を示しています。

## ユーザーがリージョン別にフィルタリングできるようにする
<a name="suggest-filter-region-examples"></a>

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

```
{
  "QueryText": "Mariot",
  "Filter": {
    "IncludeCountries": [
      "USA"
    ],
    "BoundingBox": [
      -71.15693983012913,42.261623506672635,
      -70.97249727163558,42.37584075627763
    ]
  },
  "AdditionalFeatures": [
    "Core"
  ]
}
```

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

```
{
    "ResultItems": [
        {
            "Title": "Boston Marriott Copley Place",
            "SuggestResultItemType": "Place",
            "Place": {
                "PlaceId": "Redacted",
                "PlaceType": "PointOfInterest",
                "Address": {
                    "Label": "Boston Marriott Copley Place, 110 Huntington Ave, Boston, MA 02116, United States",
                    "Country": {
                        "Code2": "US",
                        "Code3": "USA",
                        "Name": "United States"
                    },
                    "Region": {
                        "Code": "MA",
                        "Name": "Massachusetts"
                    },
                    "SubRegion": {
                        "Name": "Suffolk"
                    },
                    "Locality": "Boston",
                    "District": "Back Bay",
                    "PostalCode": "02116",
                    "Street": "Huntington Ave",
                    "StreetComponents": [
                        {
                            "BaseName": "Huntington",
                            "Type": "Ave",
                            "TypePlacement": "AfterBaseName",
                            "TypeSeparator": " ",
                            "Language": "en"
                        }
                    ],
                    "AddressNumber": "110"
                },
                "Position": [
                    -71.07769,
                    42.34726
                ],
                "Distance": 3347,
                "Categories": [
                    {
                        "Id": "hotel",
                        "Name": "Hotel",
                        "LocalizedName": "Hotel",
                        "Primary": true
                    }
                ],
                "BusinessChains": [
                    {
                        "Name": "Marriott",
                        "Id": "Marriott"
                    }
                ],
                "AccessPoints": [
                    {
                        "Position": [
                            -71.07922,
                            42.34665
                        ]
                    }
                ]
            },
            "Highlights": {
                "Title": [
                    {
                        "StartIndex": 7,
                        "EndIndex": 14,
                        "Value": "Marriot"
                    }
                ],
                "Address": {
                    "Label": [
                        {
                            "StartIndex": 7,
                            "EndIndex": 14,
                            "Value": "Marriot"
                        }
                    ]
                }
            }
        },
        ...
        {
            "Title": "Marriott",
            "SuggestResultItemType": "Query",
            "Query": {
                "QueryId": "Redacted",
                "QueryType": "BusinessChain"
            },
            "Highlights": {
                "Title": [
                    {
                        "StartIndex": 0,
                        "EndIndex": 8,
                        "Value": "Marriott"
                    }
                ]
            }
        },
        ...
    ],
    "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": "Mariot",
  "Filter": {
    "IncludeCountries": [
      "USA"
    ],
    "BoundingBox": [
      -71.15693983012913,42.261623506672635,
      -70.97249727163558,42.37584075627763
    ]
  },
  "AdditionalFeatures": [
    "Core"
  ]
}'
```

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

```
aws geo-places suggest --key ${YourKey} \
--query-text "hote" \
--filter '{"IncludeCountries": ["FRA"], "BoundingBox": [ -71.15693983012913,42.261623506672635, -70.97249727163558,42.37584075627763]}' \
--additional-features "Core"
```

------

## デベロッパー向けのヒント
<a name="suggest-filter-region-developer-tips"></a>

`Title` レスポンスフィールドを使用して検索結果を表示し、ユーザーに簡潔で認識可能なエントリを提供します。類似する可能性のある結果については、`Place.Address.Label`フィールドを使用して、ユーザーがそれらを区別するのに役立つ追加の住所の詳細を表示します。詳細については、「[ユーザーが同様の結果のあいまいさを解消する方法Suggest API を使用して結果のあいまいさを解消する](suggest-disambiguate-results.md)」を参照してください。