-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Section link:

Question 1:
Reason:
Cannot import name 'CorsOptions' from 'azure.search.documents.indexes'
Suggestion:
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import (
ComplexField,
CorsOptions,
SearchIndex,
ScoringProfile,
SearchFieldDataType,
SimpleField,
SearchableField
)
Question 2:
Reason:
azure.core.exceptions.HttpResponseError: () The request is invalid. Details: definition : The complex field 'address' cannot have the retrievable property set. Instead, set the retrievable property on sub-fields of the complex type.
Suggestion:
Update the code here as follows:
retrievable=None if search_field.hidden is None else not search_field.hidden
Script link:

Question 1:
Reason:
Name 'Index' is not defined.
Suggestion:
Update Index to SearchIndex.
Question 2:
The same problem exists in the script: sample_index_crud_operations_async.py
Reason:
create_or_update() got multiple values for keyword argument 'index_name' .
Suggestion:
result = client.create_or_update_index(index=index)
Script sample_synonym_map_operations.py and sample_synonym_map_operations_async.py

Reason:
'SynonymMap' object is not subscriptable.
Suggestion:
Update x['name'] to x.name .
Update result['synonyms'] to result.synonyms .
4.
Script sample_indexers_operations.py

Question 1:
This same problem exists in the following script: sample_indexers_operations_async.py ,
sample_indexer_datasource_skillset.py
Reason:
'SearchIndexerClient' object has no attribute 'create_datasource' .
Suggestion:
container = SearchIndexerDataContainer(name='searchcontainer')
data_source_connection = SearchIndexerDataSourceConnection(
name="indexer-datasource",
type="azureblob",
connection_string=connection_string,
container=container
)
result = indexers_client.create_data_source_connection(data_source_connection)
Question 2:
Reason:
azure.core.exceptions.HttpResponseError: () This indexer refers to an index 'hotels' that doesn't exist.
Suggestion:
Update target_index_name="hotels" to target_index_name="indexer-hotels".
5.
Script sample_data_source_operations_async.py:

Reason:
'SearchIndexerClient' object has no attribute 'delete_datasource'.
Suggestion:
Update delete_datasource to delete_data_source_connection.