azure.search.documents.models package

class azure.search.documents.models.AutocompleteMode(value)[source]

Specifies the mode for Autocomplete. The default is ‘oneTerm’. Use ‘twoTerms’ to get shingles and ‘oneTermWithContext’ to use the current context in producing autocomplete terms.

ONE_TERM = 'oneTerm'

Only one term is suggested. If the query has two terms, only the last term is completed. For #: example, if the input is ‘washington medic’, the suggested terms could include ‘medicaid’, #: ‘medicare’, and ‘medicine’.

ONE_TERM_WITH_CONTEXT = 'oneTermWithContext'

Completes the last term in a query with two or more terms, where the last two terms are a #: phrase that exists in the index. For example, if the input is ‘washington medic’, the suggested #: terms could include ‘washington medicaid’ and ‘washington medical’.

TWO_TERMS = 'twoTerms'

Matching two-term phrases in the index will be suggested. For example, if the input is ‘medic’, #: the suggested terms could include ‘medicare coverage’ and ‘medical assistant’.

class azure.search.documents.models.IndexAction(*, additional_properties: Dict[str, Any] | None = None, action_type: str | _models.IndexActionType | None = None, **kwargs: Any)[source]

Represents an index action that operates on a document.

Variables:
  • additional_properties (dict[str, any]) – Unmatched properties from the message are deserialized to this collection.

  • action_type (str or IndexActionType) – The operation to perform on a document in an indexing batch. Known values are: “upload”, “merge”, “mergeOrUpload”, and “delete”.

Keyword Arguments:
  • additional_properties (dict[str, any]) – Unmatched properties from the message are deserialized to this collection.

  • action_type (str or IndexActionType) – The operation to perform on a document in an indexing batch. Known values are: “upload”, “merge”, “mergeOrUpload”, and “delete”.

as_dict(keep_readonly: bool = True, key_transformer: ~typing.Callable[[str, ~typing.Dict[str, ~typing.Any], ~typing.Any], ~typing.Any] = <function attribute_transformer>, **kwargs: ~typing.Any) MutableMapping[str, Any]

Return a dict that can be serialized using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters:

key_transformer (function) – A key transformer function.

Returns:

A dict JSON compatible object

Return type:

dict

classmethod deserialize(data: Any, content_type: str | None = None) ModelType

Parse a str using the RestAPI syntax and return a model.

Parameters:
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns:

An instance of this model

Raises:

DeserializationError if something went wrong

classmethod enable_additional_properties_sending() None
classmethod from_dict(data: Any, key_extractors: Callable[[str, Dict[str, Any], Any], Any] | None = None, content_type: str | None = None) ModelType

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters:
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns:

An instance of this model

Raises:

DeserializationError if something went wrong

classmethod is_xml_model() bool
serialize(keep_readonly: bool = False, **kwargs: Any) MutableMapping[str, Any]

Return the JSON that would be sent to server from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters:

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns:

A dict JSON compatible object

Return type:

dict

class azure.search.documents.models.IndexingResult(**kwargs: Any)[source]

Status of an indexing operation for a single document.

Variables are only populated by the server, and will be ignored when sending a request.

All required parameters must be populated in order to send to Azure.

Variables:
  • key (str) – The key of a document that was in the indexing request. Required.

  • error_message (str) – The error message explaining why the indexing operation failed for the document identified by the key; null if indexing succeeded.

  • succeeded (bool) – A value indicating whether the indexing operation succeeded for the document identified by the key. Required.

  • status_code (int) – The status code of the indexing operation. Possible values include: 200 for a successful update or delete, 201 for successful document creation, 400 for a malformed input document, 404 for document not found, 409 for a version conflict, 422 when the index is temporarily unavailable, or 503 for when the service is too busy. Required.

as_dict(keep_readonly: bool = True, key_transformer: ~typing.Callable[[str, ~typing.Dict[str, ~typing.Any], ~typing.Any], ~typing.Any] = <function attribute_transformer>, **kwargs: ~typing.Any) MutableMapping[str, Any]

Return a dict that can be serialized using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters:

key_transformer (function) – A key transformer function.

Returns:

A dict JSON compatible object

Return type:

dict

classmethod deserialize(data: Any, content_type: str | None = None) ModelType

Parse a str using the RestAPI syntax and return a model.

Parameters:
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns:

An instance of this model

Raises:

DeserializationError if something went wrong

classmethod enable_additional_properties_sending() None
classmethod from_dict(data: Any, key_extractors: Callable[[str, Dict[str, Any], Any], Any] | None = None, content_type: str | None = None) ModelType

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters:
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns:

An instance of this model

Raises:

DeserializationError if something went wrong

classmethod is_xml_model() bool
serialize(keep_readonly: bool = False, **kwargs: Any) MutableMapping[str, Any]

Return the JSON that would be sent to server from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters:

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns:

A dict JSON compatible object

Return type:

dict

class azure.search.documents.models.QueryAnswerResult(*, additional_properties: Dict[str, Any] | None = None, **kwargs: Any)[source]

An answer is a text passage extracted from the contents of the most relevant documents that matched the query. Answers are extracted from the top search results. Answer candidates are scored and the top answers are selected.

Variables are only populated by the server, and will be ignored when sending a request.

Variables:
  • additional_properties (dict[str, any]) – Unmatched properties from the message are deserialized to this collection.

  • score (float) – The score value represents how relevant the answer is to the query relative to other answers returned for the query.

  • key (str) – The key of the document the answer was extracted from.

  • text (str) – The text passage extracted from the document contents as the answer.

  • highlights (str) – Same text passage as in the Text property with highlighted text phrases most relevant to the query.

Keyword Arguments:

additional_properties (dict[str, any]) – Unmatched properties from the message are deserialized to this collection.

as_dict(keep_readonly: bool = True, key_transformer: ~typing.Callable[[str, ~typing.Dict[str, ~typing.Any], ~typing.Any], ~typing.Any] = <function attribute_transformer>, **kwargs: ~typing.Any) MutableMapping[str, Any]

Return a dict that can be serialized using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters:

key_transformer (function) – A key transformer function.

Returns:

A dict JSON compatible object

Return type:

dict

classmethod deserialize(data: Any, content_type: str | None = None) ModelType

Parse a str using the RestAPI syntax and return a model.

Parameters:
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns:

An instance of this model

Raises:

DeserializationError if something went wrong

classmethod enable_additional_properties_sending() None
classmethod from_dict(data: Any, key_extractors: Callable[[str, Dict[str, Any], Any], Any] | None = None, content_type: str | None = None) ModelType

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters:
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns:

An instance of this model

Raises:

DeserializationError if something went wrong

classmethod is_xml_model() bool
serialize(keep_readonly: bool = False, **kwargs: Any) MutableMapping[str, Any]

Return the JSON that would be sent to server from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters:

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns:

A dict JSON compatible object

Return type:

dict

class azure.search.documents.models.QueryAnswerType(value)[source]

This parameter is only valid if the query type is semantic. If set, the query returns answers extracted from key passages in the highest ranked documents. The number of answers returned can be configured by appending the pipe character | followed by the count-<number of answers> option after the answers parameter value, such as extractive|count-3. Default count is 1. The confidence threshold can be configured by appending the pipe character | followed by the threshold-<confidence threshold> option after the answers parameter value, such as extractive|threshold-0.9. Default threshold is 0.7.

EXTRACTIVE = 'extractive'

Extracts answer candidates from the contents of the documents returned in response to a query #: expressed as a question in natural language.

NONE = 'none'

Do not return answers for the query.

class azure.search.documents.models.QueryCaptionResult(*, additional_properties: Dict[str, Any] | None = None, **kwargs: Any)[source]

Captions are the most representative passages from the document relatively to the search query. They are often used as document summary. Captions are only returned for queries of type semantic.

Variables are only populated by the server, and will be ignored when sending a request.

Variables:
  • additional_properties (dict[str, any]) – Unmatched properties from the message are deserialized to this collection.

  • text (str) – A representative text passage extracted from the document most relevant to the search query.

  • highlights (str) – Same text passage as in the Text property with highlighted phrases most relevant to the query.

Keyword Arguments:

additional_properties (dict[str, any]) – Unmatched properties from the message are deserialized to this collection.

as_dict(keep_readonly: bool = True, key_transformer: ~typing.Callable[[str, ~typing.Dict[str, ~typing.Any], ~typing.Any], ~typing.Any] = <function attribute_transformer>, **kwargs: ~typing.Any) MutableMapping[str, Any]

Return a dict that can be serialized using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters:

key_transformer (function) – A key transformer function.

Returns:

A dict JSON compatible object

Return type:

dict

classmethod deserialize(data: Any, content_type: str | None = None) ModelType

Parse a str using the RestAPI syntax and return a model.

Parameters:
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns:

An instance of this model

Raises:

DeserializationError if something went wrong

classmethod enable_additional_properties_sending() None
classmethod from_dict(data: Any, key_extractors: Callable[[str, Dict[str, Any], Any], Any] | None = None, content_type: str | None = None) ModelType

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters:
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns:

An instance of this model

Raises:

DeserializationError if something went wrong

classmethod is_xml_model() bool
serialize(keep_readonly: bool = False, **kwargs: Any) MutableMapping[str, Any]

Return the JSON that would be sent to server from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters:

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns:

A dict JSON compatible object

Return type:

dict

class azure.search.documents.models.QueryCaptionType(value)[source]

This parameter is only valid if the query type is semantic. If set, the query returns captions extracted from key passages in the highest ranked documents. When Captions is set to extractive, highlighting is enabled by default, and can be configured by appending the pipe character | followed by the highlight-<true/false> option, such as extractive|highlight-true. Defaults to None.

EXTRACTIVE = 'extractive'

Extracts captions from the matching documents that contain passages relevant to the search #: query.

NONE = 'none'

Do not return captions for the query.

class azure.search.documents.models.QueryType(value)[source]

Specifies the syntax of the search query. The default is ‘simple’. Use ‘full’ if your query uses the Lucene query syntax.

FULL = 'full'

Uses the full Lucene query syntax for searches. Search text is interpreted using the Lucene #: query language which allows field-specific and weighted searches, as well as other advanced #: features.

SEMANTIC = 'semantic'

Best suited for queries expressed in natural language as opposed to keywords. Improves #: precision of search results by re-ranking the top search results using a ranking model trained #: on the Web corpus.

SIMPLE = 'simple'

Uses the simple query syntax for searches. Search text is interpreted using a simple query #: language that allows for symbols such as +, * and “”. Queries are evaluated across all #: searchable fields by default, unless the searchFields parameter is specified.

class azure.search.documents.models.ScoringStatistics(value)[source]

A value that specifies whether we want to calculate scoring statistics (such as document frequency) globally for more consistent scoring, or locally, for lower latency. The default is ‘local’. Use ‘global’ to aggregate scoring statistics globally before scoring. Using global scoring statistics can increase latency of search queries.

GLOBAL = 'global'

The scoring statistics will be calculated globally for more consistent scoring.

LOCAL = 'local'

The scoring statistics will be calculated locally for lower latency.

class azure.search.documents.models.SearchMode(value)[source]

Specifies whether any or all of the search terms must be matched in order to count the document as a match.

ALL = 'all'

All of the search terms must be matched in order to count the document as a match.

ANY = 'any'

Any of the search terms must be matched in order to count the document as a match.

class azure.search.documents.models.SemanticErrorMode(value)[source]

Allows the user to choose whether a semantic call should fail completely, or to return partial results.

FAIL = 'fail'

If there is an exception during the semantic processing step, the query will fail and return #: the appropriate HTTP code depending on the error.

PARTIAL = 'partial'

If the semantic processing fails, partial results still return. The definition of partial #: results depends on what semantic step failed and what was the reason for failure.

class azure.search.documents.models.SemanticErrorReason(value)[source]

Reason that a partial response was returned for a semantic ranking request.

CAPACITY_OVERLOADED = 'capacityOverloaded'

The request was throttled. Only the base results were returned.

MAX_WAIT_EXCEEDED = 'maxWaitExceeded'

If semanticMaxWaitInMilliseconds was set and the semantic processing duration exceeded that #: value. Only the base results were returned.

TRANSIENT = 'transient'

At least one step of the semantic process failed.

class azure.search.documents.models.SemanticSearchResultsType(value)[source]

Type of partial response that was returned for a semantic ranking request.

BASE_RESULTS = 'baseResults'

Results without any semantic enrichment or reranking.

RERANKED_RESULTS = 'rerankedResults'

Results have been reranked with the reranker model and will include semantic captions. They #: will not include any answers, answers highlights or caption highlights.

class azure.search.documents.models.VectorFilterMode(value)[source]

Determines whether or not filters are applied before or after the vector search is performed.

POST_FILTER = 'postFilter'

The filter will be applied after the candidate set of vector results is returned. Depending on #: the filter selectivity, this can result in fewer results than requested by the parameter ‘k’.

PRE_FILTER = 'preFilter'

The filter will be applied before the search query.

class azure.search.documents.models.VectorQuery(*, k_nearest_neighbors: int | None = None, fields: str | None = None, exhaustive: bool | None = None, **kwargs: Any)[source]

The query parameters for vector and hybrid search queries.

You probably want to use the sub-classes and not this class directly. Known sub-classes are: VectorizedQuery

All required parameters must be populated in order to send to Azure.

Variables:
  • kind (str or VectorQueryKind) – The kind of vector query being performed. Required. “vector”

  • k_nearest_neighbors (int) – Number of nearest neighbors to return as top hits.

  • fields (str) – Vector Fields of type Collection(Edm.Single) to be included in the vector searched.

  • exhaustive (bool) – When true, triggers an exhaustive k-nearest neighbor search across all vectors within the vector index. Useful for scenarios where exact matches are critical, such as determining ground truth values.

Keyword Arguments:
  • k_nearest_neighbors (int) – Number of nearest neighbors to return as top hits.

  • fields (str) – Vector Fields of type Collection(Edm.Single) to be included in the vector searched.

  • exhaustive (bool) – When true, triggers an exhaustive k-nearest neighbor search across all vectors within the vector index. Useful for scenarios where exact matches are critical, such as determining ground truth values.

as_dict(keep_readonly: bool = True, key_transformer: ~typing.Callable[[str, ~typing.Dict[str, ~typing.Any], ~typing.Any], ~typing.Any] = <function attribute_transformer>, **kwargs: ~typing.Any) MutableMapping[str, Any]

Return a dict that can be serialized using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters:

key_transformer (function) – A key transformer function.

Returns:

A dict JSON compatible object

Return type:

dict

classmethod deserialize(data: Any, content_type: str | None = None) ModelType

Parse a str using the RestAPI syntax and return a model.

Parameters:
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns:

An instance of this model

Raises:

DeserializationError if something went wrong

classmethod enable_additional_properties_sending() None
classmethod from_dict(data: Any, key_extractors: Callable[[str, Dict[str, Any], Any], Any] | None = None, content_type: str | None = None) ModelType

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters:
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns:

An instance of this model

Raises:

DeserializationError if something went wrong

classmethod is_xml_model() bool
serialize(keep_readonly: bool = False, **kwargs: Any) MutableMapping[str, Any]

Return the JSON that would be sent to server from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters:

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns:

A dict JSON compatible object

Return type:

dict

class azure.search.documents.models.VectorizedQuery(*, vector: List[float], k_nearest_neighbors: int | None = None, fields: str | None = None, exhaustive: bool | None = None, **kwargs: Any)[source]

The query parameters to use for vector search when a raw vector value is provided.

All required parameters must be populated in order to send to Azure.

Variables:
  • kind (str or VectorQueryKind) – The kind of vector query being performed. Required. “vector”

  • k_nearest_neighbors (int) – Number of nearest neighbors to return as top hits.

  • fields (str) – Vector Fields of type Collection(Edm.Single) to be included in the vector searched.

  • exhaustive (bool) – When true, triggers an exhaustive k-nearest neighbor search across all vectors within the vector index. Useful for scenarios where exact matches are critical, such as determining ground truth values.

  • vector (list[float]) – The vector representation of a search query. Required.

Keyword Arguments:
  • k_nearest_neighbors (int) – Number of nearest neighbors to return as top hits.

  • fields (str) – Vector Fields of type Collection(Edm.Single) to be included in the vector searched.

  • exhaustive (bool) – When true, triggers an exhaustive k-nearest neighbor search across all vectors within the vector index. Useful for scenarios where exact matches are critical, such as determining ground truth values.

  • vector (list[float]) – The vector representation of a search query. Required.

as_dict(keep_readonly: bool = True, key_transformer: ~typing.Callable[[str, ~typing.Dict[str, ~typing.Any], ~typing.Any], ~typing.Any] = <function attribute_transformer>, **kwargs: ~typing.Any) MutableMapping[str, Any]

Return a dict that can be serialized using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters:

key_transformer (function) – A key transformer function.

Returns:

A dict JSON compatible object

Return type:

dict

classmethod deserialize(data: Any, content_type: str | None = None) ModelType

Parse a str using the RestAPI syntax and return a model.

Parameters:
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns:

An instance of this model

Raises:

DeserializationError if something went wrong

classmethod enable_additional_properties_sending() None
classmethod from_dict(data: Any, key_extractors: Callable[[str, Dict[str, Any], Any], Any] | None = None, content_type: str | None = None) ModelType

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters:
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns:

An instance of this model

Raises:

DeserializationError if something went wrong

classmethod is_xml_model() bool
serialize(keep_readonly: bool = False, **kwargs: Any) MutableMapping[str, Any]

Return the JSON that would be sent to server from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters:

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns:

A dict JSON compatible object

Return type:

dict