I'm working on building a semantic search engine using 'Azure Cognitive Search'. I uploaded my Excel dataset programmatically using Python.
To search & run the queries, each field/column in the Excel dataset can be associated with features like 'searchable', 'sortable', 'retrievable', 'filterable', & 'facetable'.
I tried selecting these features for the fields/columns in my dataset, but they are disabled somehow. Only the 'retrievable' option is selectable. I tried both programmatically & manually. Neither of these methods work.
NOTE: I'm using a free trial version. Not sure if this is causing the issue, but the documentation says, "retrievable" has no effect on index size. "filterable", "sortable", "facetable" consume more storage". Also, my data is very small with 8 rows & 10 columns, with mostly numbers & single-worded text.
What I have tried:
My Python code to select the features:
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="MySecretKey"
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