

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

# Suggest と一致したクエリ用語を強調表示する機能を使用してルートを選択する
<a name="suggest-highlight-matched-query-terms"></a>

Suggest API を使用すると、ユーザーが場所またはカテゴリの検索クエリを入力したとき、リアルタイムのオートコンプリート提案が得られます。結果は関連性に基づいてランク付けされ、最も可能性の高い一致が最初に表示されます。API レスポンスには、各提案がユーザーのクエリにどのように一致するかを示す強調表示情報が含まれます。

## 想定されるユースケース
<a name="suggest-disambiguate-results-potential-use"></a>

強調表示を使用して、各提案のどの部分が入力と一致するかをユーザーに表示することにより、必要な結果をすばやく選択しやすくなります。

## 例
<a name="suggest-hightlight-results-examples"></a>

結果リストをユーザーに表示する場合、レスポンスの **[ハイライト]** フィールドを使用して、入力が結果にどのように一致したかを特定できます。以下の例では、ユーザーは「Effel tow」のクエリを実行します。これは、**[タイトル]** 「Tour Eiffel (Eiffel Tower)」の結果と一致します。[ハイライト] 結果フィールドを使用すると、入力クエリが出力と一致した場所を示すように結果のスタイルを設定できます。その結果、テキストは「Tour Eiffel (**Eiffel Tower**)」としてユーザーに提示されます。

### Suggest API を使用してクエリ結果をハイライトする
<a name="suggest-hightlight-example"></a>

この例では、Suggest 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, * Avenue Anatole France, ***** Paris, France",
                    "Country": {
                        "Code2": "FR",
                        "Code3": "FRA",
                        "Name": "France"
                    },
                    "Region": {
                        "Code": "IDF",
                        "Name": "Île-de-France"
                    },
                    "SubRegion": {
                        "Name": "Paris"
                    },
                    "Locality": "Paris",
                    "District": "*e Arrondissement",
                    "PostalCode": "*****",
                    "Street": "Avenue Anatole France",
                    "StreetComponents": [
                        {
                            "BaseName": "Anatole France",
                            "Type": "Avenue",
                            "TypePlacement": "BeforeBaseName",
                            "TypeSeparator": " ",
                            "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"
                    }
                ],
                "Address": {}
            }
        }
    ],
    "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": 10000, "Center": [2.3431932014695382, 48.858844492141145]}, "IncludeCountries": ["FRA"]}' \
--additional-features "Core"
```

------

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

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