テキストの分析 (REST API Azure Cognitive Search)
Analyze API は、アナライザーがテキストをトークンに分割する方法を示しています。 これは、特定のアナライザーが文字列入力をトークン化する方法を確認できるように、対話型テストを目的としています。
POST https://[service name].search.windows.net/indexes/[index name]/analyze?api-version=[api-version]
Content-Type: application/json
api-key: [admin key]
インデックス作成とクエリの実行中に使用されるアナライザーを指定するには、インデックス内の文字列フィールドにアナライザー プロパティを設定します。
URI パラメーター
パラメーター | 説明 |
---|---|
サービス名 | 必須です。 これを検索サービスの一意のユーザー定義名に設定します。 |
インデックス名 | 必須です。 要求 URI は、分析するフィールドを含むインデックスの名前を指定します。 |
api-version | 必須です。 現在の安定バージョンは です api-version=2020-06-30 。 その他 のバージョンについては、「API のバージョン 」を参照してください。 |
要求ヘッダー
次の表では、必須と省略可能の要求ヘッダーについて説明します。
フィールド | 説明 |
---|---|
Content-Type | 必須です。 これを application/json |
api-key | 必須です。 api-key は Search サービスに対する要求の認証に使用されます。 これはサービスに固有の文字列値です。 アナライザー要求には、(クエリ キーではなく) 管理者キーに設定されたヘッダーを含める api-key 必要があります。 API キーは、Azure portalの検索サービス ダッシュボードにあります。 |
要求本文
{
"text": "Text to analyze",
"analyzer": "analyzer_name"
}
または
{
"text": "Text to analyze",
"tokenizer": "tokenizer_name",
"tokenFilters": (optional) [ "token_filter_name" ],
"charFilters": (optional) [ "char_filter_name" ]
}
、tokenizer_name
、token_filter_name
および char_filter_name
はanalyzer_name
、インデックスの定義済みまたはカスタム アナライザー、トークナイザー、トークン フィルター、および char フィルターの有効な名前である必要があります。 字句分析のプロセスの詳細については、「Azure Cognitive Searchの分析」を参照してください。
Response
状態コード: 応答の成功に対して「200 OK」が返されます。
応答本文の形式は次のとおりです。
{
"tokens": [
{
"token": string (token),
"startOffset": number (index of the first character of the token),
"endOffset": number (index of the last character of the token),
"position": number (position of the token in the input text)
},
...
]
}
例
要求本文には、使用する文字列とアナライザーが含まれます。
{
"text": "The quick brown fox",
"analyzer": "standard"
}
応答には、指定した文字列のアナライザーによって出力されるトークンが表示されます。
{
"tokens": [
{
"token": "the",
"startOffset": 0,
"endOffset": 3,
"position": 0
},
{
"token": "quick",
"startOffset": 4,
"endOffset": 9,
"position": 1
},
{
"token": "brown",
"startOffset": 10,
"endOffset": 15,
"position": 2
},
{
"token": "fox",
"startOffset": 16,
"endOffset": 19,
"position": 3
}
]
}