Skip to content
Draft
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
3 changes: 3 additions & 0 deletions sdk/search/azure-search-documents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

### Bugs Fixed

- Restored `KnowledgeRetrievalOutputMode` and `KnowledgeRetrievalReasoningEffort` as public re-exports from `azure.search.documents.indexes.models`.
- Restored supported public `SearchIndex.serialize()` and `SearchIndex.deserialize()` round-trip helpers.

### Other Changes

## 12.1.0b1 (2026-05-28)
Expand Down
32 changes: 32 additions & 0 deletions sdk/search/azure-search-documents/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4188,6 +4188,25 @@ namespace azure.search.documents.indexes.models
) -> None: ...


class azure.search.documents.indexes.models.KnowledgeRetrievalOutputMode(str, Enum, metaclass=CaseInsensitiveEnumMeta):
ANSWER_SYNTHESIS = "answerSynthesis"
EXTRACTIVE_DATA = "extractiveData"


class azure.search.documents.indexes.models.KnowledgeRetrievalReasoningEffort(_Model):
kind: str

@overload
def __init__(
self,
*,
kind: str
) -> None: ...

@overload
def __init__(self, mapping: Mapping[str, Any]) -> None: ...


class azure.search.documents.indexes.models.KnowledgeBaseAzureOpenAIModel(KnowledgeBaseModel, discriminator='azureOpenAI'):
azure_open_ai_parameters: AzureOpenAIVectorizerParameters
kind: Literal[KnowledgeBaseModelKind.AZURE_OPEN_AI]
Expand Down Expand Up @@ -5854,6 +5873,19 @@ namespace azure.search.documents.indexes.models
@overload
def __init__(self, mapping: Mapping[str, Any]) -> None: ...

@classmethod
def deserialize(
cls,
data: Any,
content_type: Optional[str] = None
) -> Self: ...

def serialize(
self,
keep_readonly: bool = False,
**kwargs: Any
) -> Any: ...


class azure.search.documents.indexes.models.SearchIndexFieldReference(_Model):
name: str
Expand Down
2 changes: 1 addition & 1 deletion sdk/search/azure-search-documents/api.metadata.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
apiMdSha256: cf9b5548f872667463b76b7b872cc6b9083f419238d4b4df3bc2410ad0d64c8b
apiMdSha256: 896df7d7f6f8b9614be3ad5b11fab8edbc8cfd0fbab80a5279763db0897f9e6f
parserVersion: 0.3.28
pythonVersion: 3.12.13
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
"""

import json
from enum import Enum
from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Union, overload
from azure.core import CaseInsensitiveEnumMeta
from ._models import SearchField as _SearchField
from ._models import SearchIndex as _SearchIndex
from ._models import SearchIndexerDataSourceConnection as _SearchIndexerDataSourceConnection
from ._models import KnowledgeBase as _KnowledgeBase
from ._models import SearchResourceEncryptionKey as _SearchResourceEncryptionKey
from ...knowledgebases.models._models import KnowledgeRetrievalReasoningEffort as _KnowledgeRetrievalReasoningEffort
from ._enums import (
LexicalAnalyzerName,
SearchFieldDataType as _SearchFieldDataType,
Expand Down Expand Up @@ -147,6 +152,54 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)


class SearchIndex(_SearchIndex):
"""Represents a search index definition with public round-trip helpers."""

def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)

def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> Any:
"""
Return the JSON that would be sent to the service from this model.

:param bool keep_readonly: Whether to include readonly properties in the serialized payload.
:return: A JSON-serializable representation of this model.
:rtype: Any
"""

_ = kwargs
return self.as_dict(exclude_readonly=not keep_readonly)

@classmethod
def deserialize(cls, data: Any, content_type: Optional[str] = None):
"""
Parse RestAPI-shaped data and return a model instance.

:param Any data: The serialized payload to deserialize.
:param str content_type: The payload content type. JSON is assumed unless XML is specified.
:return: A deserialized ``SearchIndex`` instance.
:rtype: ~azure.search.documents.indexes.models.SearchIndex
"""

if isinstance(data, (str, bytes, bytearray)) and content_type != "application/xml":
data = json.loads(data)
return cls(data)


class KnowledgeRetrievalOutputMode(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Compatibility export for knowledge retrieval output modes."""

ANSWER_SYNTHESIS = "answerSynthesis"
EXTRACTIVE_DATA = "extractiveData"


class KnowledgeRetrievalReasoningEffort(_KnowledgeRetrievalReasoningEffort):
"""Compatibility export for knowledge retrieval reasoning effort."""

def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)


class KnowledgeBase(_KnowledgeBase):
"""Represents a knowledge base definition."""

Expand Down Expand Up @@ -451,8 +504,11 @@ def ComplexField(

__all__: list[str] = [
"KnowledgeBase",
"KnowledgeRetrievalOutputMode",
"KnowledgeRetrievalReasoningEffort",
"SearchField",
"SearchFieldDataType",
"SearchIndex",
"SearchIndexerDataSourceConnection",
"SearchResourceEncryptionKey",
"SimpleField",
Expand Down
2 changes: 2 additions & 0 deletions sdk/search/azure-search-documents/tests/_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def _model_capabilities() -> Mapping[str, Mapping[str, Any]]:
f"{_KBM}.KnowledgeRetrievalLowReasoningEffort",
f"{_KBM}.KnowledgeRetrievalMediumReasoningEffort",
f"{_KBM}.KnowledgeRetrievalOutputMode",
f"{_IM}.KnowledgeRetrievalOutputMode",
f"{_IM}.KnowledgeRetrievalReasoningEffort",
f"{_KBM}.KnowledgeBaseModelQueryPlanningActivityRecord",
f"{_KBM}.KnowledgeBaseModelAnswerSynthesisActivityRecord",
f"{_KBM}.KnowledgeBaseModelWebSummarizationActivityRecord",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

from azure.search.documents.indexes.models import (
ComplexField,
KnowledgeRetrievalOutputMode,
KnowledgeRetrievalReasoningEffort,
SearchFieldDataType,
SearchIndex,
SearchableField,
SimpleField,
)
from _capabilities import require_capability


INDEX_NAME = "hotels"
Expand Down Expand Up @@ -97,3 +100,31 @@ def test_search_index_round_trips_helper_field_wire_shape(self):
assert index.fields[2].analyzer_name == "en.lucene"
assert index.fields[3].type == "Collection(Edm.String)"
assert index.fields[4].fields[1].name == "State"

def test_search_index_exposes_public_round_trip_helpers(self):
index = SearchIndex(name=INDEX_NAME, fields=create_hotel_fields(), e_tag="abc123")

serialized = index.serialize()
round_tripped = SearchIndex.deserialize(serialized)

assert serialized == index.as_dict()
assert isinstance(round_tripped, SearchIndex)
assert round_tripped.as_dict() == index.as_dict()

def test_indexes_models_reexports_knowledge_retrieval_types(self):
require_capability(
"azure.search.documents.indexes.models.KnowledgeRetrievalOutputMode",
"azure.search.documents.indexes.models.KnowledgeRetrievalReasoningEffort",
)

from azure.search.documents.knowledgebases.models import (
KnowledgeRetrievalOutputMode as KnowledgeRetrievalOutputModeFromKnowledgeBases,
)
from azure.search.documents.knowledgebases.models import (
KnowledgeRetrievalReasoningEffort as KnowledgeRetrievalReasoningEffortFromKnowledgeBases,
)

assert KnowledgeRetrievalOutputMode.EXTRACTIVE_DATA == (
KnowledgeRetrievalOutputModeFromKnowledgeBases.EXTRACTIVE_DATA
)
assert issubclass(KnowledgeRetrievalReasoningEffort, KnowledgeRetrievalReasoningEffortFromKnowledgeBases)
Loading