SearchIndexClient クラス

Azure Search サービス インデックスと対話するクライアント。

継承
azure.search.documents._headers_mixin.HeadersMixin
SearchIndexClient

コンストラクター

SearchIndexClient(endpoint: str, credential: AzureKeyCredential | TokenCredential, **kwargs: Any)

パラメーター

endpoint
str
必須

Azure Search サービスの URL エンドポイント

credential
AzureKeyCredential または TokenCredential
必須

検索クライアント要求を承認するための資格情報

api_version
str

要求に使用する Search API バージョン。

audience
str

は、Azure Active Directory (AAD) での認証に使用する対象ユーザーを設定します。 共有キーを使用する場合、対象ユーザーは考慮されません。 対象ユーザーが指定されていない場合、パブリック クラウドの対象ユーザーが想定されます。

メソッド

analyze_text

アナライザーがテキストをトークンに分割する方法を示します。

close

セッションを SearchIndexClient 閉じます。

create_index

新しい検索インデックスを作成します。

create_or_update_index

新しい検索インデックスを作成するか、インデックスが既に存在する場合は更新します。

create_or_update_synonym_map

Azure Search Serviceで新しいシノニム マップを作成するか、既存のシノニム マップを更新します。

create_synonym_map

Azure Search Serviceで新しいシノニム マップを作成する

delete_index

検索インデックスと、それに含まれるすべてのドキュメントを削除します。 アクセス条件を使用するには、名前の代わりにモデルを指定する必要があります。

delete_synonym_map

Azure Search Serviceで名前付きシノニム マップを削除します。 アクセス条件を使用するには、名前の代わりに SynonymMap モデルを指定する必要があります。 無条件に削除するには、シノニム マップの名前を指定するだけで十分です。

get_index
get_index_statistics

ドキュメント数やストレージ使用量など、指定されたインデックスの統計を返します。

get_search_client

検索で操作を実行するクライアントを返す

get_service_statistics

検索サービスのサービス レベルの統計情報を取得します。

get_synonym_map

Azure Search Serviceで名前付きシノニム マップを取得する

get_synonym_map_names

Azure Search Serviceのシノニム マップ名を一覧表示します。

get_synonym_maps

Azure Search Serviceのシノニム マップを一覧表示します。

list_index_names

Azure Search Service内のインデックス名を一覧表示します。

list_indexes

Azure Search Service内のインデックスを一覧表示します。

analyze_text

アナライザーがテキストをトークンに分割する方法を示します。

analyze_text(index_name: str, analyze_request: AnalyzeTextOptions, **kwargs: Any) -> AnalyzeResult

パラメーター

index_name
str
必須

アナライザーをテストするインデックスの名前。

analyze_request
AnalyzeTextOptions
必須

テストするテキストおよびアナライザーまたは分析コンポーネント。

戻り値

AnalyzeResult

の戻り値の型 :

例外

テキストを分析する


   from azure.core.credentials import AzureKeyCredential
   from azure.search.documents.indexes import SearchIndexClient
   from azure.search.documents.indexes.models import AnalyzeTextOptions

   client = SearchIndexClient(service_endpoint, AzureKeyCredential(key))

   analyze_request = AnalyzeTextOptions(text="One's <two/>", analyzer_name="standard.lucene")

   result = client.analyze_text(index_name, analyze_request)
   print(result.as_dict())

close

セッションを SearchIndexClient 閉じます。

close() -> None

例外

create_index

新しい検索インデックスを作成します。

create_index(index: SearchIndex, **kwargs: Any) -> SearchIndex

パラメーター

index
SearchIndex
必須

index オブジェクトです。

戻り値

作成されたインデックス

の戻り値の型 :

例外

新しいインデックスの作成。


   client = SearchIndexClient(service_endpoint, AzureKeyCredential(key))
   name = "hotels"
   fields = [
       SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True),
       SimpleField(name="baseRate", type=SearchFieldDataType.Double),
       SearchableField(name="description", type=SearchFieldDataType.String, collection=True),
       ComplexField(
           name="address",
           fields=[
               SimpleField(name="streetAddress", type=SearchFieldDataType.String),
               SimpleField(name="city", type=SearchFieldDataType.String),
           ],
           collection=True,
       ),
   ]
   cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60)
   scoring_profiles: List[ScoringProfile] = []
   index = SearchIndex(name=name, fields=fields, scoring_profiles=scoring_profiles, cors_options=cors_options)

   result = client.create_index(index)

create_or_update_index

新しい検索インデックスを作成するか、インデックスが既に存在する場合は更新します。

create_or_update_index(index: SearchIndex, allow_index_downtime: bool | None = None, *, match_condition: MatchConditions = MatchConditions.Unconditionally, **kwargs: Any) -> SearchIndex

パラメーター

index
SearchIndex
必須

index オブジェクトです。

allow_index_downtime
bool
必須

インデックスを少なくとも数秒間オフラインにすることで、新しいアナライザー、トークナイザー、トークン フィルター、または文字フィルターをインデックスに追加できるようにします。 これにより、インデックス作成とクエリ要求が一時的に失敗します。 インデックスを更新すると、インデックスのパフォーマンスと書き込み可用性が数分にわたり損なわれる場合があります。インデックスが非常に大きい場合、その時間も長くなります。

match_condition
MatchConditions

etag で使用する一致条件

戻り値

作成または更新されたインデックス

の戻り値の型 :

例外

インデックスを更新します。


   client = SearchIndexClient(service_endpoint, AzureKeyCredential(key))
   name = "hotels"
   fields = [
       SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True),
       SimpleField(name="baseRate", type=SearchFieldDataType.Double),
       SearchableField(name="description", type=SearchFieldDataType.String, collection=True),
       SearchableField(name="hotelName", type=SearchFieldDataType.String),
       ComplexField(
           name="address",
           fields=[
               SimpleField(name="streetAddress", type=SearchFieldDataType.String),
               SimpleField(name="city", type=SearchFieldDataType.String),
               SimpleField(name="state", type=SearchFieldDataType.String),
           ],
           collection=True,
       ),
   ]
   cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60)
   scoring_profile = ScoringProfile(name="MyProfile")
   scoring_profiles = []
   scoring_profiles.append(scoring_profile)
   index = SearchIndex(name=name, fields=fields, scoring_profiles=scoring_profiles, cors_options=cors_options)

   result = client.create_or_update_index(index=index)

create_or_update_synonym_map

Azure Search Serviceで新しいシノニム マップを作成するか、既存のシノニム マップを更新します。

create_or_update_synonym_map(synonym_map: SynonymMap, *, match_condition: MatchConditions = MatchConditions.Unconditionally, **kwargs: Any) -> SynonymMap

パラメーター

synonym_map
SynonymMap
必須

シノニム マップ オブジェクト

match_condition
MatchConditions

etag で使用する一致条件

戻り値

作成または更新されたシノニム マップ

の戻り値の型 :

例外

create_synonym_map

Azure Search Serviceで新しいシノニム マップを作成する

create_synonym_map(synonym_map: SynonymMap, **kwargs: Any) -> SynonymMap

パラメーター

synonym_map
SynonymMap
必須

シノニム マップ オブジェクト

戻り値

作成されたシノニム マップ

の戻り値の型 :

例外

シノニム マップを作成する


   synonyms = [
       "USA, United States, United States of America",
       "Washington, Wash. => WA",
   ]
   synonym_map = SynonymMap(name="test-syn-map", synonyms=synonyms)
   result = client.create_synonym_map(synonym_map)
   print("Create new Synonym Map 'test-syn-map succeeded")

delete_index

検索インデックスと、それに含まれるすべてのドキュメントを削除します。 アクセス条件を使用するには、名前の代わりにモデルを指定する必要があります。

delete_index(index: str | SearchIndex, *, match_condition: MatchConditions = MatchConditions.Unconditionally, **kwargs: Any) -> None

パラメーター

index
str または SearchIndex
必須

削除するインデックス名またはオブジェクト。

match_condition
MatchConditions

etag で使用する一致条件

例外

インデックスを削除します。


   client = SearchIndexClient(service_endpoint, AzureKeyCredential(key))
   name = "hotels"
   client.delete_index(name)

delete_synonym_map

Azure Search Serviceで名前付きシノニム マップを削除します。 アクセス条件を使用するには、名前の代わりに SynonymMap モデルを指定する必要があります。 無条件に削除するには、シノニム マップの名前を指定するだけで十分です。

delete_synonym_map(synonym_map: str | SynonymMap, *, match_condition: MatchConditions = MatchConditions.Unconditionally, **kwargs: Any) -> None

パラメーター

name
str または SynonymMap
必須

削除するシノニム マップ名またはオブジェクト

match_condition
MatchConditions

etag で使用する一致条件

戻り値

なし

の戻り値の型 :

例外

シノニム マップを削除する


   client.delete_synonym_map("test-syn-map")
   print("Synonym Map 'test-syn-map' deleted")

get_index

get_index(name: str, **kwargs: Any) -> SearchIndex

パラメーター

name
str
必須

取得するインデックスの名前。

戻り値

SearchIndex オブジェクト

の戻り値の型 :

例外

インデックスを取得します。


   client = SearchIndexClient(service_endpoint, AzureKeyCredential(key))
   name = "hotels"
   result = client.get_index(name)

get_index_statistics

ドキュメント数やストレージ使用量など、指定されたインデックスの統計を返します。

get_index_statistics(index_name: str, **kwargs: Any) -> MutableMapping[str, Any]

パラメーター

index_name
str
必須

取得するインデックスの名前。

戻り値

ドキュメント数やストレージ使用量など、特定のインデックスの統計。

の戻り値の型 :

例外

get_search_client

検索で操作を実行するクライアントを返す

get_search_client(index_name: str, **kwargs: Any) -> SearchClient

パラメーター

index_name
str
必須

検索インデックスの名前

戻り値

SearchClient オブジェクト

の戻り値の型 :

例外

get_service_statistics

検索サービスのサービス レベルの統計情報を取得します。

get_service_statistics(**kwargs: Any) -> MutableMapping[str, Any]

戻り値

サービス統計の結果。

の戻り値の型 :

例外

get_synonym_map

Azure Search Serviceで名前付きシノニム マップを取得する

get_synonym_map(name: str, **kwargs: Any) -> SynonymMap

パラメーター

name
str
必須

取得するシノニム マップの名前

戻り値

取得したシノニム マップ

の戻り値の型 :

例外

シノニム マップを取得する


   result = client.get_synonym_map("test-syn-map")
   print("Retrived Synonym Map 'test-syn-map' with synonyms")
   for syn in result.synonyms:
       print("    {}".format(syn))

get_synonym_map_names

Azure Search Serviceのシノニム マップ名を一覧表示します。

get_synonym_map_names(**kwargs: Any) -> List[str]

戻り値

シノニム マップの一覧

の戻り値の型 :

例外

get_synonym_maps

Azure Search Serviceのシノニム マップを一覧表示します。

get_synonym_maps(*, select: List[str] | None = None, **kwargs) -> List[SynonymMap]

パラメーター

select
list[str]

取得するスキルセットの最上位のプロパティを選択します。 JSON プロパティ名の一覧として指定され、すべてのプロパティに対して '*' が指定されます。 既定値はすべてのプロパティです。

戻り値

シノニム マップの一覧

の戻り値の型 :

例外

シノニム マップの一覧表示


   result = client.get_synonym_maps()
   names = [x.name for x in result]
   print("Found {} Synonym Maps in the service: {}".format(len(result), ", ".join(names)))

list_index_names

Azure Search Service内のインデックス名を一覧表示します。

list_index_names(**kwargs: Any) -> ItemPaged[str]

戻り値

インデックス名の一覧

の戻り値の型 :

例外

list_indexes

Azure Search Service内のインデックスを一覧表示します。

list_indexes(*, select: List[str] | None = None, **kwargs: Any) -> ItemPaged[SearchIndex]

パラメーター

select
list[str]

取得するスキルセットの最上位のプロパティを選択します。 JSON プロパティ名の一覧として指定され、すべてのプロパティに対して '*' が指定されます。 既定値はすべてのプロパティです。

戻り値

インデックスの一覧

の戻り値の型 :

例外