“Azure 认知搜索”-“字段”配置问题

编程


我正在致力于使用“Azure 认知搜索”构建语义搜索引擎。 我使用 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 认知搜索索引中的字段选择“可检索”属性,而“可搜索”、“可排序”、“可筛选”和“分面表”等其他属性则被禁用。

这可能与 Azure 认知搜索免费层的限制有关。 虽然文档提到“可过滤”、“可排序”和“可分面”等属性会消耗更多存储空间,但并未明确声明它们在免费套餐中被禁用。

我遇到了同样的问题。

コメント

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