Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

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="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
Posted
Updated 16-Feb-24 2:31am
v3
Comments
[no name] 1-Oct-23 11:38am    
You should find a "working example" (on the chosen platform) and tailor it to your needs instead of trying to bend things to your will.

1 solution

You're facing an issue where only the 'retrievable' attribute can be selected for the fields in your Azure Cognitive Search index, while other attributes like 'searchable', 'sortable', 'filterable', and 'facetable' are disabled.

This might be related to limitations in the free tier of Azure Cognitive Search. While the documentation mentions that attributes like 'filterable', 'sortable', and 'facetable' consume more storage, it doesn't explicitly state that they are disabled for free tiers.

I ran into the same problems.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900