Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
334 changes: 218 additions & 116 deletions sdk/search/azure-search-documents/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,12 @@ def pack_search_field(search_field):
)
fields = [pack_search_field(x) for x in search_field.fields] \
if search_field.fields else None
retrievable = not search_field.hidden if search_field.hidden is not None else None
return _SearchField(
name=search_field.name,
type=search_field.type,
key=search_field.key,
retrievable=not search_field.hidden,
retrievable=retrievable,
searchable=search_field.searchable,
filterable=search_field.filterable,
sortable=search_field.sortable,
Expand All @@ -446,11 +447,12 @@ def unpack_search_field(search_field):
return None
fields = [unpack_search_field(x) for x in search_field.fields] \
if search_field.fields else None
hidden = not search_field.retrievable if search_field.retrievable is not None else None
return _SearchField(
name=search_field.name,
type=search_field.type,
key=search_field.key,
hidden=not search_field.retrievable,
hidden=hidden,
searchable=search_field.searchable,
filterable=search_field.filterable,
sortable=search_field.sortable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def get_data_source_connection():
async def delete_data_source_connection():
# [START delete_data_source_connection_async]
async with client:
client.delete_datasource("async-sample-data-source-connection")
client.delete_data_source_connection("async-sample-data-source-connection")
print("Data Source Connection 'async-sample-data-source-connection' successfully deleted")
# [END delete_data_source_connection_async]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async def update_index():
scoring_profiles=scoring_profiles,
cors_options=cors_options)

result = await client.create_or_update_index(index_name=index.name, index=index)
result = await client.create_or_update_index(index=index)
# [END update_index_async]

async def delete_index():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@

from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes.models import (
SearchIndexerDataContainer, SearchIndex, SearchIndexer, SimpleField, SearchFieldDataType
SearchIndexerDataContainer,
SearchIndexerDataSourceConnection,
SearchIndex,
SearchIndexer,
SimpleField,
SearchFieldDataType
)
from azure.search.documents.indexes.aio import SearchIndexerClient, SearchIndexClient

Expand All @@ -41,23 +46,28 @@ async def create_indexer():
SimpleField(name="baseRate", type=SearchFieldDataType.Double)
]
index = SearchIndex(name=index_name, fields=fields)
ind_client = SearchIndexClient(service_endpoint, AzureKeyCredential(key))
ind_client = SearchIndexerClient(service_endpoint, AzureKeyCredential(key))
async with ind_client:
await ind_client.create_index(index)

# [START create_indexer_async]
# create a datasource
container = SearchIndexerDataContainer(name='searchcontainer')
data_source_connection = SearchIndexerDataSourceConnection(
name="indexer-datasource",
type="azureblob",
connection_string=connection_string,
container=container
)
async with ind_client:
data_source = await ind_client.create_datasource(
name="async-indexer-datasource",
type="azureblob",
connection_string=connection_string,
container=container
)
data_source = await ind_client.create_data_source_connection(data_source_connection)

# create an indexer
indexer = SearchIndexer(name="async-sample-indexer", data_source_name="async-indexer-datasource", target_index_name="hotels")
indexer = SearchIndexer(
name="async-sample-indexer",
data_source_name="async-indexer-datasource",
target_index_name="indexer-hotels"
)
async with indexers_client:
result = await indexers_client.create_indexer(indexer)
print("Create new Indexer - async-sample-indexer")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ async def create_synonym_map():
async def get_synonym_maps():
# [START get_synonym_maps_async]
result = await client.get_synonym_maps()
names = [x["name"] for x in result]
names = [x.name for x in result]
print("Found {} Synonym Maps in the service: {}".format(len(result), ", ".join(names)))
# [END get_synonym_maps_async]

async def get_synonym_map():
# [START get_synonym_map_async]
result = await client.get_synonym_map("test-syn-map")
print("Retrived Synonym Map 'test-syn-map' with synonyms")
for syn in result["synonyms"]:
for syn in result.synonyms:
print(" {}".format(syn))
# [END get_synonym_map_async]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ def update_index():
)
scoring_profiles = []
scoring_profiles.append(scoring_profile)
index = Index(
index = SearchIndex(
name=name,
fields=fields,
scoring_profiles=scoring_profiles,
cors_options=cors_options)

result = client.create_or_update_index(index_name=index.name, index=index)
result = client.create_or_update_index(index=index)
# [END update_index]

def delete_index():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@

from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes.models import (
SearchIndexerDataContainer, SearchIndex, SearchIndexer, SimpleField, SearchFieldDataType
SearchIndexerDataContainer,
SearchIndexerDataSourceConnection,
SearchIndex,
SearchIndexer,
SimpleField,
SearchFieldDataType
)
from azure.search.documents.indexes import SearchIndexClient, SearchIndexerClient

Expand All @@ -46,15 +51,20 @@ def create_indexer():
# [START create_indexer]
# create a datasource
container = SearchIndexerDataContainer(name='searchcontainer')
data_source = indexers_client.create_datasource(
data_source_connection = SearchIndexerDataSourceConnection(
name="indexer-datasource",
type="azureblob",
connection_string=connection_string,
container=container
)
data_source = indexers_client.create_data_source_connection(data_source_connection)

# create an indexer
indexer = SearchIndexer(name="sample-indexer", data_source_name="indexer-datasource", target_index_name="hotels")
indexer = SearchIndexer(
name="sample-indexer",
data_source_name="indexer-datasource",
target_index_name="indexer-hotels"
)
result = indexers_client.create_indexer(indexer)
print("Create new Indexer - sample-indexer")
# [END create_indexer]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ def create_synonym_map():
def get_synonym_maps():
# [START get_synonym_maps]
result = client.get_synonym_maps()
names = [x["name"] for x in result]
names = [x.name for x in result]
print("Found {} Synonym Maps in the service: {}".format(len(result), ", ".join(names)))
# [END get_synonym_maps]

def get_synonym_map():
# [START get_synonym_map]
result = client.get_synonym_map("test-syn-map")
print("Retrived Synonym Map 'test-syn-map' with synonyms")
for syn in result["synonyms"]:
for syn in result.synonyms:
print(" {}".format(syn))
# [END get_synonym_map]

Expand Down