2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Azure AI Search(旧Cognitive Search) ベクトル クエリの python ライブラリバージョンアップ対応

Posted at

背景

ライブラリアップデート

  • ライブラリをアンインストール
    • pip uninstall azure-search-documents
  • バージョン指定してライブラリをインストール
    • pip install azure-search-documents==11.4.0

プログラム修正

11.4.0 のインタフェースに合わせて修正する
参考までに過去バージョンサンプルも載せる

11.4.0
from azure.search.documents import SearchClient
from azure.search.documents.models import VectorizedQuery
:
:
results = search_client.search(
    search_text=tmp_search_text,
    vector_queries=[
        VectorizedQuery(
            kind="vector", vector=tmp_vector, k_nearest_neighbors=3, fields="embedding"
        )
    ],
)
11.4.0b08
from azure.search.documents import SearchClient
from azure.search.documents.models import Vector
:
:
results = search_client.search(
    search_text=tmp_search_text,
    vectors=[Vector(value=tmp_vector, k=3, fields="embedding")],
)
11.4.0b06
from azure.search.documents import SearchClient
:
:
results = search_client.search(
    search_text=tmp_search_text,
    vector=tmp_vector,
    vector_fields="embedding",
    top_k=3)

参考

以下ソースの tag を切り替えるとインタフェースを確認できる
https://github.com/Azure/azure-sdk-for-python/blob/azure-search-documents_11.4.0/sdk/search/azure-search-documents/azure/search/documents/_search_client.py

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?