Note
Foundry IQ (Azure AI 検索) は、マネージド取得用の上位レベルのナレッジ ソースおよびナレッジ ベース API と共に、直接インデックス作成およびクエリ API を提供します。 Azure ポータル、REST API、またはAzure SDKを使用してこれらの機能を構成するか、Microsoft Foundry ポータルでエージェントをナレッジ ベースに接続します。
Important
トピック グラフの取得はパブリック プレビュー段階であり、Microsoft Azure Previews の追加使用条件に従います。 この機能に固有のプレビューに関する条件については、「プレビュー機能」を参照してください。
ベクター クエリは、クエリ ベクターに最も近い最近傍 k を返します。 多くのドキュメントが同じテーマをカバーしている場合、そのような近似一致によって、他のテーマに関する関連するドキュメントが埋もれてしまうことがあります。
トピック グラフ サンプリング (プレビュー) では、トピック インデックスを使用して、最も関連性の高い結果を保持しながら、コレクション内のテーマにベクター クエリの結果を分散します。
この記事では、コンテンツ インデックス内のベクター フィールドをトピック インデックスにリンクし、格納されている既定のトピック グラフ サンプリング設定、または要求に対するオーバーライドを使用するベクター クエリを実行します。 代わりにナレッジ ベースを通じてトピック グラフ サンプリングを使用するには、「 トピック グラフの取得を構成する」を参照してください。
使用サポート
| Azure portal | Microsoft Foundry ポータル | .NET SDK | Python SDK | Java SDK | JavaScript SDK | REST API |
|---|---|---|---|---|---|---|
| ❌ | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Prerequisites
同じサービスにデータが投入されたトピック インデックス。 Foundry IQ スキル プラグインは、コンテンツのトピック インデックスを準備します。 サービスに必要なスキーマについては、「 トピック インデックスの要件」を参照してください。
同じサービス上の既存のコンテンツが格納されたコンテンツ インデックス。 トピック インデックスと同じ型、ディメンション、および類似性メトリックを使用するベクター フィールドが必要です。 例ではテキスト クエリを使用するため、ベクター フィールドには vectorizer が必要です。
コンテンツ インデックスを更新してクエリを実行するアクセス許可。 キーレス認証を構成するには Search Service 共同作成者 ロールを使用してインデックスを更新し、クエリを実行するには 検索インデックス データ閲覧者 ロールを使用します。 クエリ ID は、コンテンツ インデックスとトピック インデックスの両方を読み取ることができる必要があります。
最新の
Azure.Search.Documentsプレビュー パッケージ:dotnet add package Azure.Search.Documents --prereleaseキーレス認証の場合、
Azure.Identityパッケージは次のようになります。dotnet add package Azure.Identity
最新の
azure-search-documentsプレビュー パッケージ:pip install --pre azure-search-documentsキーレス認証の場合、
azure-identityパッケージは次のようになります。pip install azure-identity
Search Service REST API の 2026-11-01-preview バージョン。
キーレス認証の場合は、各 HTTP 要求の
AuthorizationヘッダーにMicrosoft Entra ID トークンを含めます。
トピック グラフサンプリングのしくみ
トピック インデックスには、トピックごとに 1 つのドキュメントが格納されます。 各ドキュメントには、トピック識別子と、トピックのコンテンツを表す 重心 ベクトルがあります。 ベクター クエリでトピック グラフ サンプリングを使用する場合、Foundry IQ:
- コンテンツ インデックスから候補ドキュメントのオーバーサンプリング されたプールを取得します。 プールには、少なくとも最小多様性プール サイズ、またはその値のほうが大きい場合は少なくとも
kの 2 倍があります。 - 重心がクエリ ベクターに最も似ているトピック インデックス内のトピックを検索し、各候補を最も近いトピックに割り当てます。
- トピック間で結果を選択します。 各ラウンドで、最も関連性の高い残りの候補を含むトピックがその候補を提示します。 その候補の関連性が、先頭トピックの次の候補の 多様性要因 の範囲内にある場合、他の各トピックが最適な残りの候補を提供します。 多様性係数は、
0から1までの相対的な低下幅です。 より高い要因は、より多くのトピックからの関連性の低い候補を認めます。
次の 3 種類のサンプリングのいずれかを選択します。
| サブタイプ | Behavior |
|---|---|
balanced |
トピックサンプリングされた結果を最も類似した結果とインターリーブします。
0.2の固定された多様性係数を使用します。 最も近い一致を維持しながら、多様性を追加するための開始点として使用します。 |
diverse |
トピックでサンプリングされた結果を返します。
diversityFactorを設定して、結果がトピック全体にどの程度分散するかを制御します。 |
none |
トピック グラフのサンプリングをオフにします。 このクエリは、類似性の順序で最も近い近傍を返します。 |
サンプリングされた結果は元の @search.score 値を保持し、応答の形状は他のベクター クエリ応答と同じです。 サンプリングはトピック間で結果を並べ替えるので、結果は必ずしもスコアで並べ替えられるとは限りません。
トピック インデックスの要件
コンテンツ インデックスにリンクすると、サービスによってトピック インデックスがチェックされます。 トピック インデックスは、次の要件を満たしている必要があります。
| 要件 | Details |
|---|---|
| 場所 | 同じサービス上の既存のインデックス。 コンテンツ インデックスにはできません。 |
subject_id field |
トピック識別子を保持する最上位の文字列フィールド。 |
object_vector field |
トピックの重心を保持する最上位のベクター フィールド。
storedをfalseに設定することはできません。 コンテンツ インデックス ベクター フィールドの種類、ディメンション、および類似性メトリックと一致する必要があります。 |
| Permissions | トピック インデックスとコンテンツ インデックスのどちらも、ドキュメント レベルのアクセス制御を使用できません。 |
ベクトル フィールドをトピック インデックスにリンクする
トピック グラフ プロファイルをコンテンツ インデックスに追加し、ベクター フィールドに割り当てます。 プロファイルには、トピック インデックスと、そのフィールドのベクター クエリに適用される既定のサンプリングの種類の名前が付けられます。 最初にインデックスを作成し、次に別個の更新でトピック グラフ プロファイルを追加します。 プロファイルを含む作成要求は失敗します。
この記事の例では、 id キー フィールド、検索可能な content フィールド、および embedding ベクター フィールドを含むコンテンツ インデックスを使用します。
using Azure.Identity;
using Azure.Search.Documents.Indexes;
using Azure.Search.Documents.Indexes.Models;
using Azure.Search.Documents.Models;
var endpoint = new Uri("<search-endpoint>");
var credential = new DefaultAzureCredential();
var indexName = "<content-index-name>";
var topicIndexName = "<topic-index-name>";
var indexClient = new SearchIndexClient(endpoint, credential);
SearchIndex index = await indexClient.GetIndexAsync(indexName);
index.VectorSearch.TopicGraphProfiles.Add(
new VectorSearchTopicGraphProfile(
"content-topics", topicIndexName, VectorSearchTopicGraphKind.Balanced));
index.Fields.Single(field => field.Name == "embedding").TopicGraphProfile =
"content-topics";
await indexClient.CreateOrUpdateIndexAsync(index);
Reference:SearchIndexClient
from azure.identity import DefaultAzureCredential
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import VectorSearchTopicGraphProfile
from azure.search.documents.models import VectorSearchTopicGraphKind
endpoint = "<search-endpoint>"
credential = DefaultAzureCredential()
index_name = "<content-index-name>"
topic_index_name = "<topic-index-name>"
index_client = SearchIndexClient(endpoint, credential)
index = index_client.get_index(index_name)
index.vector_search.topic_graph_profiles = [
VectorSearchTopicGraphProfile(
name="content-topics",
index_name=topic_index_name,
default_kind=VectorSearchTopicGraphKind.BALANCED,
)
]
vector_field = next(f for f in index.fields if f.name == "embedding")
vector_field.topic_graph_profile = "content-topics"
index_client.create_or_update_index(index)
Reference:SearchIndexClient
PUT要求は、インデックス定義全体を置き換えます。 同じ URL に対する GET 要求を含むインデックスの現在の定義を取得し、 topicGraphProfile プロパティをベクター フィールドに追加し、 topicGraphProfiles 配列を vectorSearchに追加して、完全な定義を送信します。 次の例は、 embedding フィールドが text-embedding-3-small ベクタライザーを使用するインデックスの完全な定義を示しています。
@api-version = 2026-11-01-preview
@index-url = {{search-endpoint}}/indexes/{{content-index-name}}
PUT {{index-url}}?api-version={{api-version}}
Content-Type: application/json
Authorization: Bearer {{search-access-token}}
{
"name": "{{content-index-name}}",
"fields": [
{"name": "id", "type": "Edm.String", "key": true},
{"name": "content", "type": "Edm.String", "searchable": true},
{
"name": "embedding",
"type": "Collection(Edm.Single)",
"searchable": true,
"dimensions": 1536,
"vectorSearchProfile": "vector-profile",
"topicGraphProfile": "content-topics"
}
],
"vectorSearch": {
"algorithms": [
{"name": "hnsw", "kind": "hnsw", "hnswParameters": {"metric": "cosine"}}
],
"vectorizers": [
{
"name": "embedding-vectorizer",
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"resourceUri": "{{aoai-endpoint}}",
"deploymentId": "text-embedding-3-small",
"modelName": "text-embedding-3-small"
}
}
],
"profiles": [
{
"name": "vector-profile",
"algorithm": "hnsw",
"vectorizer": "embedding-vectorizer"
}
],
"topicGraphProfiles": [
{
"name": "content-topics",
"indexName": "{{topic-index-name}}",
"defaultKind": "balanced"
}
]
}
}
リファレンス:インデックス - 作成または更新
要求は 204 No Contentを返します。
要求は、トピック インデックスが 要件を満たしている場合に成功します。 リンクを確認するには、インデックス定義を取得し、ベクター フィールドのトピック グラフ プロファイルが content-topics であることを確認します。
プロファイルの既定値を使用したクエリ
ベクトル クエリがトピック グラフ プロファイルを持つフィールドを対象とする場合、プロファイルの既定のサンプリングの種類が自動的に適用されます。 既存のベクター クエリを変更する必要はありません。
using Azure.Identity;
using Azure.Search.Documents;
using Azure.Search.Documents.Models;
var endpoint = new Uri("<search-endpoint>");
var credential = new DefaultAzureCredential();
var indexName = "<content-index-name>";
var searchClient = new SearchClient(endpoint, indexName, credential);
var options = new SearchOptions
{
VectorSearch = new VectorSearchOptions
{
Queries =
{
new VectorizableTextQuery(
"What do employees say about the hybrid work program?")
{
KNearestNeighborsCount = 10,
Fields = { "embedding" }
}
}
},
Select = { "id", "content" },
Size = 10
};
SearchResults<SearchDocument> results =
await searchClient.SearchAsync<SearchDocument>(options);
Reference:SearchClient
from azure.identity import DefaultAzureCredential
from azure.search.documents import SearchClient
from azure.search.documents.models import VectorizableTextQuery
endpoint = "<search-endpoint>"
credential = DefaultAzureCredential()
index_name = "<content-index-name>"
search_client = SearchClient(endpoint, index_name, credential)
vector_query = VectorizableTextQuery(
text="What do employees say about the hybrid work program?",
k_nearest_neighbors=10,
fields="embedding",
)
results = search_client.search(
vector_queries=[vector_query], select=["id", "content"], top=10
)
Reference:SearchClient
@api-version = 2026-11-01-preview
@index-url = {{search-endpoint}}/indexes/{{content-index-name}}
POST {{index-url}}/docs/search?api-version={{api-version}}
Content-Type: application/json
Authorization: Bearer {{search-access-token}}
{
"select": "id, content",
"top": 10,
"vectorQueries": [
{
"kind": "text",
"text": "What do employees say about the hybrid work program?",
"fields": "embedding",
"k": 10
}
]
}
Reference:Documents - Search Post
balancedの既定値では、クエリに関連するトピックがある場合は、複数のトピックのドキュメントが結果に含まれます。 応答にトピックの割り当ては表示されません。 その効果を確認するには、返されたドキュメントを、クエリのサンプリングをオフにするのクエリ結果と比較します。 サンプリングされた結果には異なるドキュメントが含まれることがあります。また、それらの @search.score 値が必ずしも降順であるとは限りません。
クエリのサンプリングをオーバーライドする
1 件のリクエストのサンプリングを変更するには、ベクター クエリでトピック グラフ オプションを設定します。 プロファイルの既定値は明示的な設定で置き換えられます。 次の例では、多様性係数diverseで0.5を使用して、より多くのトピックに結果を分散します。
using Azure.Identity;
using Azure.Search.Documents;
using Azure.Search.Documents.Models;
var endpoint = new Uri("<search-endpoint>");
var credential = new DefaultAzureCredential();
var indexName = "<content-index-name>";
var searchClient = new SearchClient(endpoint, indexName, credential);
var options = new SearchOptions
{
VectorSearch = new VectorSearchOptions
{
Queries =
{
new VectorizableTextQuery(
"What do employees say about the hybrid work program?")
{
KNearestNeighborsCount = 10,
Fields = { "embedding" },
TopicGraph = new DiverseVectorQueryTopicGraph { DiversityFactor = 0.5f }
}
}
},
Select = { "id", "content" },
Size = 10
};
SearchResults<SearchDocument> results =
await searchClient.SearchAsync<SearchDocument>(options);
Reference:VectorizableTextQuery
代わりに balanced の種類を要求に使用するには、 TopicGraph を new BalancedVectorQueryTopicGraph() に設定します。
from azure.identity import DefaultAzureCredential
from azure.search.documents import SearchClient
from azure.search.documents.models import (
DiverseVectorQueryTopicGraph,
VectorizableTextQuery,
)
endpoint = "<search-endpoint>"
credential = DefaultAzureCredential()
index_name = "<content-index-name>"
search_client = SearchClient(endpoint, index_name, credential)
vector_query = VectorizableTextQuery(
text="What do employees say about the hybrid work program?",
k_nearest_neighbors=10,
fields="embedding",
topic_graph=DiverseVectorQueryTopicGraph(diversity_factor=0.5),
)
results = search_client.search(
vector_queries=[vector_query], select=["id", "content"], top=10
)
Reference:VectorizableTextQuery
代わりに balanced の種類を要求に使用するには、 topic_graph を BalancedVectorQueryTopicGraph() に設定します。
@api-version = 2026-11-01-preview
@index-url = {{search-endpoint}}/indexes/{{content-index-name}}
POST {{index-url}}/docs/search?api-version={{api-version}}
Content-Type: application/json
Authorization: Bearer {{search-access-token}}
{
"select": "id, content",
"top": 10,
"vectorQueries": [
{
"kind": "text",
"text": "What do employees say about the hybrid work program?",
"fields": "embedding",
"k": 10,
"topicGraph": {"kind": "diverse", "diversityFactor": 0.5}
}
]
}
Reference:Documents - Search Post
代わりに balanced の種類を要求に使用するには、 topicGraph を {"kind": "balanced"} に設定します。
複数のトピックが関連する場合、結果は最も類似した結果が混ざって表示されるのではなく、トピックごとに交互に表示されます。
クエリのサンプリングをオフにする
結果を比較したり、純粋な類似性の結果を返したりするには、種類を noneに設定します。
using Azure.Identity;
using Azure.Search.Documents;
using Azure.Search.Documents.Models;
var endpoint = new Uri("<search-endpoint>");
var credential = new DefaultAzureCredential();
var indexName = "<content-index-name>";
var searchClient = new SearchClient(endpoint, indexName, credential);
var options = new SearchOptions
{
VectorSearch = new VectorSearchOptions
{
Queries =
{
new VectorizableTextQuery(
"What do employees say about the hybrid work program?")
{
KNearestNeighborsCount = 10,
Fields = { "embedding" },
TopicGraph = new NoneVectorQueryTopicGraph()
}
}
},
Select = { "id", "content" },
Size = 10
};
SearchResults<SearchDocument> results =
await searchClient.SearchAsync<SearchDocument>(options);
Reference:VectorizableTextQuery
from azure.identity import DefaultAzureCredential
from azure.search.documents import SearchClient
from azure.search.documents.models import (
NoneVectorQueryTopicGraph,
VectorizableTextQuery,
)
endpoint = "<search-endpoint>"
credential = DefaultAzureCredential()
index_name = "<content-index-name>"
search_client = SearchClient(endpoint, index_name, credential)
vector_query = VectorizableTextQuery(
text="What do employees say about the hybrid work program?",
k_nearest_neighbors=10,
fields="embedding",
topic_graph=NoneVectorQueryTopicGraph(),
)
results = search_client.search(
vector_queries=[vector_query], select=["id", "content"], top=10
)
Reference:VectorizableTextQuery
@api-version = 2026-11-01-preview
@index-url = {{search-endpoint}}/indexes/{{content-index-name}}
POST {{index-url}}/docs/search?api-version={{api-version}}
Content-Type: application/json
Authorization: Bearer {{search-access-token}}
{
"select": "id, content",
"top": 10,
"vectorQueries": [
{
"kind": "text",
"text": "What do employees say about the hybrid work program?",
"fields": "embedding",
"k": 10,
"topicGraph": {"kind": "none"}
}
]
}
Reference:Documents - Search Post
結果は類似性の順序で最も近い近傍であり、トピック グラフ プロファイルのないフィールドのベクター クエリと同じです。
トピック グラフのサンプリング設定を調整する
プロファイルで既定値を設定し、クエリごとにオーバーライドします。
プロファイル設定は、DefaultMinDiversityPoolSizeのVectorSearchTopicGraphProfile、DefaultKind、およびDefaultDiversityFactorプロパティです。 クエリ設定は、 TopicGraphに割り当てるクラスのプロパティです。
プロファイル設定は、default_min_diversity_pool_size の VectorSearchTopicGraphProfile、default_kind、および default_diversity_factor パラメーターです。 クエリ設定は、 topic_graphに割り当てるクラスのパラメーターです。
プロファイル設定は、 topicGraphProfiles エントリのプロパティです。 クエリ設定は、ベクター クエリの topicGraph オブジェクトのプロパティです。
| プロファイル設定 | クエリ設定 | 値と既定値 |
|---|---|---|
defaultKind |
kind |
必須: none、 diverse、または balanced。 |
defaultDiversityFactor |
diversityFactor |
diverseのみ。 包括範囲: 0 ~ 1。 クエリで省略した場合、プロファイルの値が適用されます。 どちらも設定していない場合、既定値は 0.2。 |
defaultMinDiversityPoolSize |
minDiversityPoolSize |
diverseまたはbalancedの場合のみ。 包括範囲: 250 ~ 10000。 クエリで省略した場合、プロファイルの値が適用されます。 どちらも設定していない場合、既定値は 1000。 |
balanced を起動します。 それでも結果がトピック数が少なすぎる状態に集中する場合は、diverse を使用し、多様性の要因を増やします。 結果に関連性の低いドキュメントが多すぎる場合は、係数を下げます。
係数 0 では、結果が類似度順に返されます。
制限事項
- インデックスには、1 つのトピック グラフ プロファイルを含めることができます。
- トピック グラフ プロファイルと
topicGraphクエリ パラメーターには、2026-11-01-previewREST API またはそれをサポートするプレビュー クライアント ライブラリが必要です。2026-10-01API バージョンを使用するクエリでは、プロファイルが無視され、類似性の順序で最も近い近隣が返されます。 - トピック グラフ プロファイルが参照している間は、トピック インデックスを削除できません。 最初に、コンテンツ インデックスからプロファイルを削除するか、コンテンツ インデックスを削除します。 プロファイルを削除するには、フィールドの
topicGraphProfileプロパティとtopicGraphProfilesエントリを含めずにコンテンツ インデックスを更新します。
Troubleshooting
| エラー メッセージ | アクション |
|---|---|
| topicGraph を構成する前に、インデックスを作成する必要があります。 | プロファイルなしでコンテンツ インデックスを作成し、その後、プロファイルを追加するために更新します。 |
| トピック グラフ インデックス 'name' が存在しないか、使用できません。 | プロファイルの indexNameを確認し、トピック インデックスが同じサービスに存在することを確認します。 |
| トピック グラフ インデックス 'name' は、'subject_id' という名前の最上位の文字列フィールドを定義する必要があります。 |
要件を満たすトピック インデックスを使用します。
object_vector フィールドまたはドキュメント レベルのアクセス許可に関するエラーは、トピック インデックスが要件を満たしていないことを意味します。 |
| 1 つのインデックスに対して構成できるトピック グラフ プロファイルは 1 つだけです。 | 1 つのプロファイルを vectorSearch.topicGraphProfilesに保持します。 |
| どのベクター フィールドにも topicGraphProfile が構成されていません。 |
topicGraphProfileを持つベクター フィールドに対してクエリを実行するか、クエリからtopicGraphを削除します。 |
| ベクター クエリの 'topicGraph.diversityFactor' パラメーターは、'topicGraph.kind' が 'diverse' に設定されている場合にのみ使用できます。 |
diversityFactorを削除するか、kindをdiverseに設定します。 |
| 1 つ以上のトピック グラフ プロファイルが参照しているため、インデックス 'name' を削除できません。 これらの参照を削除または更新してください... | トピック インデックスを削除する前に、コンテンツ インデックスからプロファイルを削除するか、コンテンツ インデックスを削除してください。 |