diff --git a/sdk/search/azure-search-documents/CHANGELOG.md b/sdk/search/azure-search-documents/CHANGELOG.md index 2506e9adc214..4a1bd49f692b 100644 --- a/sdk/search/azure-search-documents/CHANGELOG.md +++ b/sdk/search/azure-search-documents/CHANGELOG.md @@ -6,6 +6,7 @@ - Reorganized `SearchServiceClient` into `SearchIndexClient` & `SearchIndexerClient` #11507 - Split searchindex.json and searchservice.json models and operations into separate namespaces #11508 +- Renamed `edm` to `SearchFieldDataType` #11511 - Now Search Synonym Map creation/update returns a model #11514 ## 1.0.0b3 (2020-05-04) diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/__init__.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/__init__.py index 11b14c02fb89..f416b5efafd4 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/__init__.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/__init__.py @@ -10,4 +10,4 @@ from ._search_index_client import SearchIndexClient # pylint: disable=unused-import from ._search_indexer_client import SearchIndexerClient # pylint: disable=unused-import -from . import edm # pylint: disable=unused-import +from . import _edm as SearchFieldDataType # pylint: disable=unused-import diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/edm.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/_edm.py similarity index 100% rename from sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/edm.py rename to sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/_edm.py diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/_index.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/_index.py index e8601794c933..f04e97e50ac1 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/_index.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/_index.py @@ -5,7 +5,7 @@ # -------------------------------------------------------------------------- from typing import TYPE_CHECKING -from .edm import Collection, ComplexType +from ._edm import Collection, ComplexType from ._generated.models import SearchField if TYPE_CHECKING: @@ -21,14 +21,15 @@ def SimpleField(**kw): :param name: Required. The name of the field, which must be unique within the fields collection of the index or parent field. :type name: str - :param type: Required. The data type of the field. Possible values include: edm.String, - edm.Int32, edm.Int64, edm.Double, edm.Boolean, edm.DateTimeOffset, - edm.GeographyPoint, edm.ComplexType, from `azure.search.documents.edm`. + :param type: Required. The data type of the field. Possible values include: SearchFieldDataType.String, + SearchFieldDataType.Int32, SearchFieldDataType.Int64, SearchFieldDataType.Double, SearchFieldDataType.Boolean, + SearchFieldDataType.DateTimeOffset, SearchFieldDataType.GeographyPoint, SearchFieldDataType.ComplexType, + from `azure.search.documents.SearchFieldDataType`. :type type: str :param key: A value indicating whether the field uniquely identifies documents in the index. Exactly one top-level field in each index must be chosen as the key field and it must be of - type Edm.String. Key fields can be used to look up documents directly and update or delete - specific documents. Default is False + type SearchFieldDataType.String. Key fields can be used to look up documents directly and + update or delete specific documents. Default is False :type key: bool :param hidden: A value indicating whether the field can be returned in a search result. You can enable this option if you want to use a field (for example, margin) as a filter, @@ -39,10 +40,10 @@ def SimpleField(**kw): :type retrievable: bool :param filterable: A value indicating whether to enable the field to be referenced in $filter queries. filterable differs from searchable in how strings are handled. Fields of type - Edm.String or Collection(Edm.String) that are filterable do not undergo word-breaking, so - comparisons are for exact matches only. For example, if you set such a field f to "sunny day", - $filter=f eq 'sunny' will find no matches, but $filter=f eq 'sunny day' will. This property - must be null for complex fields. Default is False + SearchFieldDataType.String or Collection(SearchFieldDataType.String) that are filterable do + not undergo word-breaking, so comparisons are for exact matches only. For example, if you + set such a field f to "sunny day", $filter=f eq 'sunny' will find no matches, but + $filter=f eq 'sunny day' will. This property must be null for complex fields. Default is False :type filterable: bool :param sortable: A value indicating whether to enable the field to be referenced in $orderby expressions. By default Azure Cognitive Search sorts results by score, but in many experiences @@ -56,8 +57,8 @@ def SimpleField(**kw): :param facetable: A value indicating whether to enable the field to be referenced in facet queries. Typically used in a presentation of search results that includes hit count by category (for example, search for digital cameras and see hits by brand, by megapixels, by price, and so - on). Fields of type edm.GeographyPoint or Collection(edm.GeographyPoint) cannot be facetable. - Default is False. + on). Fields of type SearchFieldDataType.GeographyPoint or + Collection(SearchFieldDataType.GeographyPoint) cannot be facetable. Default is False. :type facetable: bool """ result = {"name": kw.get("name"), "type": kw.get("type")} # type: Dict[str, Any] @@ -77,12 +78,12 @@ def SearchableField(**kw): :param name: Required. The name of the field, which must be unique within the fields collection of the index or parent field. :type name: str - :param type: Required. The data type of the field. Possible values include: edm.String - and Collection(edm.String), from `azure.search.documents.edm`. + :param type: Required. The data type of the field. Possible values include: SearchFieldDataType.String + and Collection(SearchFieldDataType.String), from `azure.search.documents.SearchFieldDataType`. :type type: str :param key: A value indicating whether the field uniquely identifies documents in the index. Exactly one top-level field in each index must be chosen as the key field and it must be of - type Edm.String. Key fields can be used to look up documents directly and update or delete + type SearchFieldDataType.String. Key fields can be used to look up documents directly and update or delete specific documents. Default is False :type key: bool :param hidden: A value indicating whether the field can be returned in a search result. diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/models/__init__.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/models/__init__.py index 63e4cac9cfe4..19627e3e2dca 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/models/__init__.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/models/__init__.py @@ -28,7 +28,7 @@ ComplexField, SearchableField, SimpleField, - edm, + SearchFieldDataType, ) from .._internal._generated.models import ( AnalyzeRequest, @@ -210,5 +210,5 @@ "UniqueTokenFilter", "WebApiSkill", "WordDelimiterTokenFilter", - "edm", + "SearchFieldDataType", ) diff --git a/sdk/search/azure-search-documents/samples/sample_index_crud_operations.py b/sdk/search/azure-search-documents/samples/sample_index_crud_operations.py index 51c4cc1d2e5d..8b96f495a0c1 100644 --- a/sdk/search/azure-search-documents/samples/sample_index_crud_operations.py +++ b/sdk/search/azure-search-documents/samples/sample_index_crud_operations.py @@ -25,7 +25,16 @@ key = os.getenv("AZURE_SEARCH_API_KEY") from azure.core.credentials import AzureKeyCredential -from azure.search.documents import ComplexField, SearchServiceClient, CorsOptions, Index, ScoringProfile, edm, SimpleField, SearchableField +from azure.search.documents import ( + ComplexField, + SearchServiceClient, + CorsOptions, + Index, + ScoringProfile, + SearchFieldDataType, + SimpleField, + SearchableField, +) client = SearchServiceClient(service_endpoint, AzureKeyCredential(key)).get_indexes_client() @@ -33,12 +42,12 @@ def create_index(): # [START create_index] name = "hotels" fields = [ - SimpleField(name="hotelId", type=edm.String, key=True), - SimpleField(name="baseRate", type=edm.Double), - SearchableField(name="description", type=edm.String), + SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True), + SimpleField(name="baseRate", type=SearchFieldDataType.Double), + SearchableField(name="description", type=SearchFieldDataType.String), ComplexField(name="address", fields=[ - SimpleField(name="streetAddress", type=edm.String), - SimpleField(name="city", type=edm.String), + SimpleField(name="streetAddress", type=SearchFieldDataType.String), + SimpleField(name="city", type=SearchFieldDataType.String), ]) ] cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60) @@ -62,14 +71,14 @@ def update_index(): # [START update_index] name = "hotels" fields = [ - SimpleField(name="hotelId", type=edm.String, key=True), - SimpleField(name="baseRate", type=edm.Double), - SearchableField(name="description", type=edm.String), - SearchableField(name="hotelName", type=edm.String), + SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True), + SimpleField(name="baseRate", type=SearchFieldDataType.Double), + SearchableField(name="description", type=SearchFieldDataType.String), + SearchableField(name="hotelName", type=SearchFieldDataType.String), ComplexField(name="address", fields=[ - SimpleField(name="streetAddress", type=edm.String), - SimpleField(name="city", type=edm.String), - SimpleField(name="state", type=edm.String), + SimpleField(name="streetAddress", type=SearchFieldDataType.String), + SimpleField(name="city", type=SearchFieldDataType.String), + SimpleField(name="state", type=SearchFieldDataType.String), ]) ] cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60) diff --git a/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py b/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py index 974276e8b89d..5d737cfa9d00 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py +++ b/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py @@ -35,7 +35,7 @@ SearchIndexer, SynonymMap, SimpleField, - edm + SearchFieldDataType ) from azure.search.documents.indexes.aio import SearchIndexClient, SearchIndexerClient @@ -160,8 +160,8 @@ async def test_delete_indexes_if_unchanged(self, api_key, endpoint, index_name, async def test_create_index(self, api_key, endpoint, index_name, **kwargs): name = "hotels" fields = fields = [ - SimpleField(name="hotelId", type=edm.String, key=True), - SimpleField(name="baseRate", type=edm.Double) + SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True), + SimpleField(name="baseRate", type=SearchFieldDataType.Double) ] scoring_profile = ScoringProfile( @@ -187,8 +187,8 @@ async def test_create_index(self, api_key, endpoint, index_name, **kwargs): async def test_create_or_update_index(self, api_key, endpoint, index_name, **kwargs): name = "hotels" fields = fields = [ - SimpleField(name="hotelId", type=edm.String, key=True), - SimpleField(name="baseRate", type=edm.Double) + SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True), + SimpleField(name="baseRate", type=SearchFieldDataType.Double) ] cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60) diff --git a/sdk/search/azure-search-documents/tests/test_index_field_helpers.py b/sdk/search/azure-search-documents/tests/test_index_field_helpers.py index 4758a09ee6be..10ce0d7f5f38 100644 --- a/sdk/search/azure-search-documents/tests/test_index_field_helpers.py +++ b/sdk/search/azure-search-documents/tests/test_index_field_helpers.py @@ -3,24 +3,24 @@ # Licensed under the MIT License. # ------------------------------------ -from azure.search.documents.indexes.models import ComplexField, SearchableField, SimpleField, edm +from azure.search.documents.indexes.models import ComplexField, SearchableField, SimpleField, SearchFieldDataType def test_edm_contents(): - assert edm.String == "Edm.String" - assert edm.Int32 == "Edm.Int32" - assert edm.Int64 == "Edm.Int64" - assert edm.Double == "Edm.Double" - assert edm.Boolean == "Edm.Boolean" - assert edm.DateTimeOffset == "Edm.DateTimeOffset" - assert edm.GeographyPoint == "Edm.GeographyPoint" - assert edm.ComplexType == "Edm.ComplexType" - assert edm.Collection("foo") == "Collection(foo)" + assert SearchFieldDataType.String == "Edm.String" + assert SearchFieldDataType.Int32 == "Edm.Int32" + assert SearchFieldDataType.Int64 == "Edm.Int64" + assert SearchFieldDataType.Double == "Edm.Double" + assert SearchFieldDataType.Boolean == "Edm.Boolean" + assert SearchFieldDataType.DateTimeOffset == "Edm.DateTimeOffset" + assert SearchFieldDataType.GeographyPoint == "Edm.GeographyPoint" + assert SearchFieldDataType.ComplexType == "Edm.ComplexType" + assert SearchFieldDataType.Collection("foo") == "Collection(foo)" class TestComplexField(object): def test_single(self): fld = ComplexField(name="foo", fields=[]) assert fld.name == "foo" - assert fld.type == edm.ComplexType + assert fld.type == SearchFieldDataType.ComplexType assert fld.sortable is None assert fld.facetable is None @@ -34,7 +34,7 @@ def test_single(self): def test_collection(self): fld = ComplexField(name="foo", fields=[], collection=True) assert fld.name == "foo" - assert fld.type == edm.Collection(edm.ComplexType) + assert fld.type == SearchFieldDataType.Collection(SearchFieldDataType.ComplexType) assert fld.sortable is None assert fld.facetable is None @@ -47,9 +47,9 @@ def test_collection(self): class TestSimplexField(object): def test_defaults(self): - fld = SimpleField(name="foo", type=edm.Double) + fld = SimpleField(name="foo", type=SearchFieldDataType.Double) assert fld.name == "foo" - assert fld.type == edm.Double + assert fld.type == SearchFieldDataType.Double assert fld.retrievable == True assert fld.sortable == False assert fld.facetable == False @@ -63,9 +63,9 @@ def test_defaults(self): class TestSearchableField(object): def test_defaults(self): - fld = SearchableField(name="foo", type=edm.Collection(edm.String)) + fld = SearchableField(name="foo", type=SearchFieldDataType.Collection(SearchFieldDataType.String)) assert fld.name == "foo" - assert fld.type == edm.Collection(edm.String) + assert fld.type == SearchFieldDataType.Collection(SearchFieldDataType.String) assert fld.retrievable == True assert fld.sortable == False assert fld.facetable == False diff --git a/sdk/search/azure-search-documents/tests/test_service_live.py b/sdk/search/azure-search-documents/tests/test_service_live.py index f9172b1e906f..c46e88bdc0b8 100644 --- a/sdk/search/azure-search-documents/tests/test_service_live.py +++ b/sdk/search/azure-search-documents/tests/test_service_live.py @@ -32,7 +32,7 @@ SearchIndexerDataContainer, SynonymMap, SimpleField, - edm + SearchFieldDataType ) from azure.search.documents.indexes import SearchIndexClient, SearchIndexerClient @@ -144,8 +144,8 @@ def test_delete_indexes_if_unchanged(self, api_key, endpoint, index_name, **kwar def test_create_index(self, api_key, endpoint, index_name, **kwargs): name = "hotels" fields = [ - SimpleField(name="hotelId", type=edm.String, key=True), - SimpleField(name="baseRate", type=edm.Double) + SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True), + SimpleField(name="baseRate", type=SearchFieldDataType.Double) ] scoring_profile = ScoringProfile( name="MyProfile" @@ -170,8 +170,8 @@ def test_create_index(self, api_key, endpoint, index_name, **kwargs): def test_create_or_update_index(self, api_key, endpoint, index_name, **kwargs): name = "hotels" fields = [ - SimpleField(name="hotelId", type=edm.String, key=True), - SimpleField(name="baseRate", type=edm.Double) + SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True), + SimpleField(name="baseRate", type=SearchFieldDataType.Double) ] cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60) scoring_profiles = []