【解決方法】「Azure コグニティブ検索」 – 「フィールド」構成の問題


私は「Azure Cognitive Search」を使用したセマンティック検索エンジンの構築に取り組んでいます。 Python を使用してプログラムで Excel データセットをアップロードしました。

クエリを検索して実行するには、Excel データセットの各フィールド/列を「検索可能」、「並べ替え可能」、「取得可能」、「フィルター可能」、「ファセットテーブル」などの機能に関連付けることができます。

データセットのフィールド/列に対してこれらの機能を選択しようとしましたが、どういうわけか無効になっています。 「取得可能」オプションのみが選択可能です。 プログラムと手動の両方を試しました。 これらの方法はどちらも機能しません。

注記: 無料試用版を使用しています。 これが問題の原因かどうかはわかりませんが、ドキュメントには「取得可能」はインデックスのサイズに影響を与えないと記載されています。 「フィルター可能」、「並べ替え可能」、「ファセット可能」はより多くのストレージを消費します。また、私のデータは 8 行 10 列と非常に小さく、ほとんどが数字と単一の単語のテキストです。

私が試したこと:

機能を選択するための私の Python コード:

Python
import pandas as pd
import json
from azure.search.documents.indexes.models import SimpleField, SearchFieldDataType
import os
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes import SearchIndexClient 
from azure.search.documents import SearchClient

df_azure=pd.read_excel("C:/stats.xlsx")

endpoint="https://azure-service.search.windows.net"
key="q5EMEa0at5VJRvwTVlkqWhvHSKs"

SearchIndexClient=SearchIndexClient(endpoint, AzureKeyCredential(key))
indexName="indexes-azure"

from azure.search.documents.indexes.models import (
    ComplexField,
    CorsOptions,
    SearchIndex,
    ScoringProfile,
    SearchFieldDataType,
    SimpleField,
    SearchableField
)

fields=[
     SearchableField(name="rule_name", type=SearchFieldDataType.String, 
                     facetable=True, filterable=True, sortable=True),
     SearchableField(name="rule_description", type=SearchFieldDataType.String, 
                     facetable=True, filterable=True, sortable=True),
     SearchableField(name="Date_of_execution", 
                     type=SearchFieldDataType.String, facetable=True, 
                     filterable=True, sortable=True),
     SearchableField(name="Data_Source", type=SearchFieldDataType.String, 
                     facetable=True, filterable=True, sortable=True),  
     SearchableField(name="Total_no_of_records", 
                     type=SearchFieldDataType.String, 
                     facetable=True, filterable=True, sortable=True),
     SearchableField(name="No_of_failed_records", 
                     type=SearchFieldDataType.String, facetable=True, 
                     filterable=True, sortable=True)
] 
  
indexConfig= SearchIndex(name=indexName,
                         fields=fields,
                         scoring_profiles=[],
                         cors_options= CorsOptions(allowed_origins=["*"], 
                         max_age_in_seconds=60))

index=SearchIndexClient.create_index(indexConfig)

SearchClient = SearchClient(endpoint, indexName, AzureKeyCredential(key))
result = SearchClient.upload_documents(documents=DOCUMENTS)
print("DOCUMENT upload successful: {}".format(result[0].succeeded))
Output: DOCUMENT upload successful: True

解決策 1

Azure Cognitive Search インデックスのフィールドに対して “retrievable” 属性のみを選択でき、”searchable”、”sortable”、”filterable”、”facetable” などの他の属性が無効になるという問題に直面しています。

これは、Azure Cognitive Search の無料利用枠の制限に関連している可能性があります。 ドキュメントには、「filterable」、「sortable」、「facetable」などの属性がより多くのストレージを消費すると記載されていますが、無料利用枠ではこれらの属性が無効になるとは明示的に記載されていません。

私も同じ問題に遭遇しました。

コメント

タイトルとURLをコピーしました