page_type | languages | products | |||
---|---|---|---|---|---|
sample |
|
|
These code samples show common scenario operations with the Azure Cognitive Search client library.
Authenticate the client with a Azure Cognitive Search API Key Credential:
https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/search/azure-search-documents/samples/sample_authentication.py (async version)
Then for common search index operations:
-
Get a document by key: sample_get_document.py (async version)
-
Perform a simple text query: sample_simple_query.py (async version)
-
Perform a filtered query: sample_filter_query.py (async version)
-
Perform a faceted query: sample_facet_query.py (async version)
-
Get auto-completions: sample_autocomplete.py (async version)
-
Get search suggestions: sample_suggestions.py (async version)
-
Perform basic document updates: sample_crud_operations.py (async version)
-
CRUD operations for index: sample_index_crud_operations.py (async version)
-
Analyze text: sample_analyze_text.py (async version)
-
CRUD operations for indexers: sample_indexers_operations.py (async version)
-
General workflow of indexer, datasource and index: sample_indexer_datasource_skillset.py
-
Semantic search: sample_semantic_search.py
-
Vector search: sample_vector_search.py (async version)
- Python 3.8 or later is required to use this package
- You must have an Azure subscription
- You must create the "Hotels" sample index in the Azure Portal
-
Install the Azure Cognitive Search client library for Python with pip:
pip install azure-search-documents --pre
-
Clone or download this repository
-
Open this sample folder in Visual Studio Code or your IDE of choice.
- Open a terminal window and
cd
to the directory that the samples are saved in. - Set the environment variables specified in the sample file you wish to run.
- Follow the usage described in the file, e.g.
python sample_simple_query.py
Check out the API reference documentation to learn more about what you can do with the Azure Cognitive Search client library.