azure.search.documents.models package

class azure.search.documents.models.AnswerResult(*, additional_properties: Optional[Dict[str, Any]] = None, **kwargs)[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=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify 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, content_type=None)

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()
classmethod from_dict(data, key_extractors=None, content_type=None)

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()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure 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

validate()

Validate this model recursively and return a list of ValidationError.

Returns

A list of validation error

Return type

list

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.CaptionResult(*, additional_properties: Optional[Dict[str, Any]] = None, **kwargs)[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=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify 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, content_type=None)

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()
classmethod from_dict(data, key_extractors=None, content_type=None)

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()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure 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

validate()

Validate this model recursively and return a list of ValidationError.

Returns

A list of validation error

Return type

list

class azure.search.documents.models.IndexAction(*, additional_properties: Optional[Dict[str, Any]] = None, action_type: Optional[Union[str, azure.search.documents._generated.models._search_client_enums.IndexActionType]] = None, **kwargs)[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. Possible values include: “upload”, “merge”, “mergeOrUpload”, “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. Possible values include: “upload”, “merge”, “mergeOrUpload”, “delete”.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify 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, content_type=None)

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()
classmethod from_dict(data, key_extractors=None, content_type=None)

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()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure 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

validate()

Validate this model recursively and return a list of ValidationError.

Returns

A list of validation error

Return type

list

class azure.search.documents.models.IndexingResult(**kwargs)[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) – Required. The key of a document that was in the indexing request.

  • 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) – Required. A value indicating whether the indexing operation succeeded for the document identified by the key.

  • status_code (int) – Required. 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.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify 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, content_type=None)

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()
classmethod from_dict(data, key_extractors=None, content_type=None)

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()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure 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

validate()

Validate this model recursively and return a list of ValidationError.

Returns

A list of validation error

Return type

list

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.

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.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.QueryLanguage(value)[source]

The language of the query.

AR_EG = 'ar-eg'

Query language value for Arabic (Egypt).

AR_JO = 'ar-jo'

Query language value for Arabic (Jordan).

AR_KW = 'ar-kw'

Query language value for Arabic (Kuwait).

AR_MA = 'ar-ma'

Query language value for Arabic (Morocco).

AR_SA = 'ar-sa'

Query language value for Arabic (Saudi Arabia).

BG_BG = 'bg-bg'

Query language value for Bulgarian (Bulgaria).

BN_IN = 'bn-in'

Query language value for Bengali (India).

CA_ES = 'ca-es'

Query language value for Catalan (Spain).

CS_CZ = 'cs-cz'

Query language value for Czech (Czech Republic).

DA_DK = 'da-dk'

Query language value for Danish (Denmark).

DE_DE = 'de-de'

Query language value for German (Germany).

EL_GR = 'el-gr'

Query language value for Greek (Greece).

EN_AU = 'en-au'

Query language value for English (Australia).

EN_CA = 'en-ca'

Query language value for English (Canada).

EN_GB = 'en-gb'

Query language value for English (Great Britain).

EN_IN = 'en-in'

Query language value for English (India).

EN_US = 'en-us'

Query language value for English (United States).

ES_ES = 'es-es'

Query language value for Spanish (Spain).

ES_MX = 'es-mx'

Query language value for Spanish (Mexico).

ET_EE = 'et-ee'

Query language value for Estonian (Estonia).

EU_ES = 'eu-es'

Query language value for Basque (Spain).

FA_AE = 'fa-ae'

Query language value for Persian (U.A.E.).

FI_FI = 'fi-fi'

Query language value for Finnish (Finland).

FR_CA = 'fr-ca'

Query language value for French (Canada).

FR_FR = 'fr-fr'

Query language value for French (France).

GA_IE = 'ga-ie'

Query language value for Irish (Ireland).

GL_ES = 'gl-es'

Query language value for Galician (Spain).

GU_IN = 'gu-in'

Query language value for Gujarati (India).

HE_IL = 'he-il'

Query language value for Hebrew (Israel).

HI_IN = 'hi-in'

Query language value for Hindi (India).

HR_BA = 'hr-ba'

Query language value for Croatian (Bosnia and Herzegovina).

HR_HR = 'hr-hr'

Query language value for Croatian (Croatia).

HU_HU = 'hu-hu'

Query language value for Hungarian (Hungary).

HY_AM = 'hy-am'

Query language value for Armenian (Armenia).

ID_ID = 'id-id'

Query language value for Indonesian (Indonesia).

IS_IS = 'is-is'

Query language value for Icelandic (Iceland).

IT_IT = 'it-it'

Query language value for Italian (Italy).

JA_JP = 'ja-jp'

Query language value for Japanese (Japan).

KN_IN = 'kn-in'

Query language value for Kannada (India).

KO_KR = 'ko-kr'

Query language value for Korean (Korea).

LT_LT = 'lt-lt'

Query language value for Lithuanian (Lithuania).

LV_LV = 'lv-lv'

Query language value for Latvian (Latvia).

ML_IN = 'ml-in'

Query language value for Malayalam (India).

MR_IN = 'mr-in'

Query language value for Marathi (India).

MS_BN = 'ms-bn'

Query language value for Malay (Brunei Darussalam).

MS_MY = 'ms-my'

Query language value for Malay (Malaysia).

NB_NO = 'nb-no'

Query language value for Norwegian (Norway).

NL_BE = 'nl-be'

Query language value for Dutch (Belgium).

NL_NL = 'nl-nl'

Query language value for Dutch (Netherlands).

NONE = 'none'

Query language not specified.

NO_NO = 'no-no'

Query language value for Norwegian (Norway).

PA_IN = 'pa-in'

Query language value for Punjabi (India).

PL_PL = 'pl-pl'

Query language value for Polish (Poland).

PT_BR = 'pt-br'

Query language value for Portuguese (Brazil).

PT_PT = 'pt-pt'

Query language value for Portuguese (Portugal).

RO_RO = 'ro-ro'

Query language value for Romanian (Romania).

RU_RU = 'ru-ru'

Query language value for Russian (Russia).

SK_SK = 'sk-sk'

Query language value for Slovak (Slovakia).

SL_SL = 'sl-sl'

Query language value for Slovenian (Slovenia).

SR_BA = 'sr-ba'

Query language value for Serbian (Bosnia and Herzegovina).

SR_ME = 'sr-me'

Query language value for Serbian (Montenegro).

SR_RS = 'sr-rs'

Query language value for Serbian (Serbia).

SV_SE = 'sv-se'

Query language value for Swedish (Sweden).

TA_IN = 'ta-in'

Query language value for Tamil (India).

TE_IN = 'te-in'

Query language value for Telugu (India).

TH_TH = 'th-th'

Query language value for Thai (Thailand).

TR_TR = 'tr-tr'

Query language value for Turkish (Turkey).

UK_UA = 'uk-ua'

Query language value for Ukrainian (Ukraine).

UR_PK = 'ur-pk'

Query language value for Urdu (Pakistan).

VI_VN = 'vi-vn'

Query language value for Vietnamese (Viet Nam).

ZH_CN = 'zh-cn'

Query language value for Chinese (China).

ZH_TW = 'zh-tw'

Query language value for Chinese (Taiwan).

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

Improve search recall by spell-correcting individual search query terms.

LEXICON = 'lexicon'

Speller corrects individual query terms using a static lexicon for the language specified by the queryLanguage parameter.

NONE = 'none'

Speller not enabled.

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 and ‘semantic’ if query syntax is not needed.

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_ENUM = '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.

azure.search.documents.models.odata(statement, **kwargs)[source]

Escape an OData query string.

The statement to prepare should include fields to substitute given inside braces, e.g. {somevar} and then pass the corresponding value as a keyword argument, e.g. somevar=10.

Parameters

statement (str) – An OData query string to prepare

Return type

str

Example:

>>> odata("name eq {name} and age eq {age}", name="O'Neil", age=37)
"name eq 'O''Neil' and age eq 37"