Skip to content

Commit 0f7a5c6

Browse files
authored
rename edm to SearchFieldDataType (#11597)
* rename edm to SearchFieldDataType
1 parent 8518e6d commit 0f7a5c6

File tree

9 files changed

+68
-57
lines changed

9 files changed

+68
-57
lines changed

sdk/search/azure-search-documents/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Reorganized `SearchServiceClient` into `SearchIndexClient` & `SearchIndexerClient` #11507
88
- Split searchindex.json and searchservice.json models and operations into separate namespaces #11508
9+
- Renamed `edm` to `SearchFieldDataType` #11511
910
- Now Search Synonym Map creation/update returns a model #11514
1011

1112
## 1.0.0b3 (2020-05-04)

sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
from ._search_index_client import SearchIndexClient # pylint: disable=unused-import
1111
from ._search_indexer_client import SearchIndexerClient # pylint: disable=unused-import
1212

13-
from . import edm # pylint: disable=unused-import
13+
from . import _edm as SearchFieldDataType # pylint: disable=unused-import

sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/_index.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# --------------------------------------------------------------------------
66
from typing import TYPE_CHECKING
77

8-
from .edm import Collection, ComplexType
8+
from ._edm import Collection, ComplexType
99
from ._generated.models import SearchField
1010

1111
if TYPE_CHECKING:
@@ -21,14 +21,15 @@ def SimpleField(**kw):
2121
:param name: Required. The name of the field, which must be unique within the fields collection
2222
of the index or parent field.
2323
:type name: str
24-
:param type: Required. The data type of the field. Possible values include: edm.String,
25-
edm.Int32, edm.Int64, edm.Double, edm.Boolean, edm.DateTimeOffset,
26-
edm.GeographyPoint, edm.ComplexType, from `azure.search.documents.edm`.
24+
:param type: Required. The data type of the field. Possible values include: SearchFieldDataType.String,
25+
SearchFieldDataType.Int32, SearchFieldDataType.Int64, SearchFieldDataType.Double, SearchFieldDataType.Boolean,
26+
SearchFieldDataType.DateTimeOffset, SearchFieldDataType.GeographyPoint, SearchFieldDataType.ComplexType,
27+
from `azure.search.documents.SearchFieldDataType`.
2728
:type type: str
2829
:param key: A value indicating whether the field uniquely identifies documents in the index.
2930
Exactly one top-level field in each index must be chosen as the key field and it must be of
30-
type Edm.String. Key fields can be used to look up documents directly and update or delete
31-
specific documents. Default is False
31+
type SearchFieldDataType.String. Key fields can be used to look up documents directly and
32+
update or delete specific documents. Default is False
3233
:type key: bool
3334
:param hidden: A value indicating whether the field can be returned in a search result.
3435
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):
3940
:type retrievable: bool
4041
:param filterable: A value indicating whether to enable the field to be referenced in $filter
4142
queries. filterable differs from searchable in how strings are handled. Fields of type
42-
Edm.String or Collection(Edm.String) that are filterable do not undergo word-breaking, so
43-
comparisons are for exact matches only. For example, if you set such a field f to "sunny day",
44-
$filter=f eq 'sunny' will find no matches, but $filter=f eq 'sunny day' will. This property
45-
must be null for complex fields. Default is False
43+
SearchFieldDataType.String or Collection(SearchFieldDataType.String) that are filterable do
44+
not undergo word-breaking, so comparisons are for exact matches only. For example, if you
45+
set such a field f to "sunny day", $filter=f eq 'sunny' will find no matches, but
46+
$filter=f eq 'sunny day' will. This property must be null for complex fields. Default is False
4647
:type filterable: bool
4748
:param sortable: A value indicating whether to enable the field to be referenced in $orderby
4849
expressions. By default Azure Cognitive Search sorts results by score, but in many experiences
@@ -56,8 +57,8 @@ def SimpleField(**kw):
5657
:param facetable: A value indicating whether to enable the field to be referenced in facet
5758
queries. Typically used in a presentation of search results that includes hit count by category
5859
(for example, search for digital cameras and see hits by brand, by megapixels, by price, and so
59-
on). Fields of type edm.GeographyPoint or Collection(edm.GeographyPoint) cannot be facetable.
60-
Default is False.
60+
on). Fields of type SearchFieldDataType.GeographyPoint or
61+
Collection(SearchFieldDataType.GeographyPoint) cannot be facetable. Default is False.
6162
:type facetable: bool
6263
"""
6364
result = {"name": kw.get("name"), "type": kw.get("type")} # type: Dict[str, Any]
@@ -77,12 +78,12 @@ def SearchableField(**kw):
7778
:param name: Required. The name of the field, which must be unique within the fields collection
7879
of the index or parent field.
7980
:type name: str
80-
:param type: Required. The data type of the field. Possible values include: edm.String
81-
and Collection(edm.String), from `azure.search.documents.edm`.
81+
:param type: Required. The data type of the field. Possible values include: SearchFieldDataType.String
82+
and Collection(SearchFieldDataType.String), from `azure.search.documents.SearchFieldDataType`.
8283
:type type: str
8384
:param key: A value indicating whether the field uniquely identifies documents in the index.
8485
Exactly one top-level field in each index must be chosen as the key field and it must be of
85-
type Edm.String. Key fields can be used to look up documents directly and update or delete
86+
type SearchFieldDataType.String. Key fields can be used to look up documents directly and update or delete
8687
specific documents. Default is False
8788
:type key: bool
8889
:param hidden: A value indicating whether the field can be returned in a search result.

sdk/search/azure-search-documents/azure/search/documents/indexes/models/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
ComplexField,
2929
SearchableField,
3030
SimpleField,
31-
edm,
31+
SearchFieldDataType,
3232
)
3333
from .._internal._generated.models import (
3434
AnalyzeRequest,
@@ -208,5 +208,5 @@
208208
"UniqueTokenFilter",
209209
"WebApiSkill",
210210
"WordDelimiterTokenFilter",
211-
"edm",
211+
"SearchFieldDataType",
212212
)

sdk/search/azure-search-documents/samples/sample_index_crud_operations.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,29 @@
2525
key = os.getenv("AZURE_SEARCH_API_KEY")
2626

2727
from azure.core.credentials import AzureKeyCredential
28-
from azure.search.documents import ComplexField, SearchServiceClient, CorsOptions, Index, ScoringProfile, edm, SimpleField, SearchableField
28+
from azure.search.documents import (
29+
ComplexField,
30+
SearchServiceClient,
31+
CorsOptions,
32+
Index,
33+
ScoringProfile,
34+
SearchFieldDataType,
35+
SimpleField,
36+
SearchableField,
37+
)
2938

3039
client = SearchServiceClient(service_endpoint, AzureKeyCredential(key)).get_indexes_client()
3140

3241
def create_index():
3342
# [START create_index]
3443
name = "hotels"
3544
fields = [
36-
SimpleField(name="hotelId", type=edm.String, key=True),
37-
SimpleField(name="baseRate", type=edm.Double),
38-
SearchableField(name="description", type=edm.String),
45+
SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True),
46+
SimpleField(name="baseRate", type=SearchFieldDataType.Double),
47+
SearchableField(name="description", type=SearchFieldDataType.String),
3948
ComplexField(name="address", fields=[
40-
SimpleField(name="streetAddress", type=edm.String),
41-
SimpleField(name="city", type=edm.String),
49+
SimpleField(name="streetAddress", type=SearchFieldDataType.String),
50+
SimpleField(name="city", type=SearchFieldDataType.String),
4251
])
4352
]
4453
cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60)
@@ -62,14 +71,14 @@ def update_index():
6271
# [START update_index]
6372
name = "hotels"
6473
fields = [
65-
SimpleField(name="hotelId", type=edm.String, key=True),
66-
SimpleField(name="baseRate", type=edm.Double),
67-
SearchableField(name="description", type=edm.String),
68-
SearchableField(name="hotelName", type=edm.String),
74+
SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True),
75+
SimpleField(name="baseRate", type=SearchFieldDataType.Double),
76+
SearchableField(name="description", type=SearchFieldDataType.String),
77+
SearchableField(name="hotelName", type=SearchFieldDataType.String),
6978
ComplexField(name="address", fields=[
70-
SimpleField(name="streetAddress", type=edm.String),
71-
SimpleField(name="city", type=edm.String),
72-
SimpleField(name="state", type=edm.String),
79+
SimpleField(name="streetAddress", type=SearchFieldDataType.String),
80+
SimpleField(name="city", type=SearchFieldDataType.String),
81+
SimpleField(name="state", type=SearchFieldDataType.String),
7382
])
7483
]
7584
cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60)

sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
SearchIndexer,
3535
SynonymMap,
3636
SimpleField,
37-
edm
37+
SearchFieldDataType
3838
)
3939
from azure.search.documents.indexes.aio import SearchIndexClient, SearchIndexerClient
4040

@@ -159,8 +159,8 @@ async def test_delete_indexes_if_unchanged(self, api_key, endpoint, index_name,
159159
async def test_create_index(self, api_key, endpoint, index_name, **kwargs):
160160
name = "hotels"
161161
fields = fields = [
162-
SimpleField(name="hotelId", type=edm.String, key=True),
163-
SimpleField(name="baseRate", type=edm.Double)
162+
SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True),
163+
SimpleField(name="baseRate", type=SearchFieldDataType.Double)
164164
]
165165

166166
scoring_profile = ScoringProfile(
@@ -186,8 +186,8 @@ async def test_create_index(self, api_key, endpoint, index_name, **kwargs):
186186
async def test_create_or_update_index(self, api_key, endpoint, index_name, **kwargs):
187187
name = "hotels"
188188
fields = fields = [
189-
SimpleField(name="hotelId", type=edm.String, key=True),
190-
SimpleField(name="baseRate", type=edm.Double)
189+
SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True),
190+
SimpleField(name="baseRate", type=SearchFieldDataType.Double)
191191
]
192192

193193
cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60)

sdk/search/azure-search-documents/tests/test_index_field_helpers.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
# Licensed under the MIT License.
44
# ------------------------------------
55

6-
from azure.search.documents.indexes.models import ComplexField, SearchableField, SimpleField, edm
6+
from azure.search.documents.indexes.models import ComplexField, SearchableField, SimpleField, SearchFieldDataType
77

88
def test_edm_contents():
9-
assert edm.String == "Edm.String"
10-
assert edm.Int32 == "Edm.Int32"
11-
assert edm.Int64 == "Edm.Int64"
12-
assert edm.Double == "Edm.Double"
13-
assert edm.Boolean == "Edm.Boolean"
14-
assert edm.DateTimeOffset == "Edm.DateTimeOffset"
15-
assert edm.GeographyPoint == "Edm.GeographyPoint"
16-
assert edm.ComplexType == "Edm.ComplexType"
17-
assert edm.Collection("foo") == "Collection(foo)"
9+
assert SearchFieldDataType.String == "Edm.String"
10+
assert SearchFieldDataType.Int32 == "Edm.Int32"
11+
assert SearchFieldDataType.Int64 == "Edm.Int64"
12+
assert SearchFieldDataType.Double == "Edm.Double"
13+
assert SearchFieldDataType.Boolean == "Edm.Boolean"
14+
assert SearchFieldDataType.DateTimeOffset == "Edm.DateTimeOffset"
15+
assert SearchFieldDataType.GeographyPoint == "Edm.GeographyPoint"
16+
assert SearchFieldDataType.ComplexType == "Edm.ComplexType"
17+
assert SearchFieldDataType.Collection("foo") == "Collection(foo)"
1818

1919
class TestComplexField(object):
2020
def test_single(self):
2121
fld = ComplexField(name="foo", fields=[])
2222
assert fld.name == "foo"
23-
assert fld.type == edm.ComplexType
23+
assert fld.type == SearchFieldDataType.ComplexType
2424

2525
assert fld.sortable is None
2626
assert fld.facetable is None
@@ -34,7 +34,7 @@ def test_single(self):
3434
def test_collection(self):
3535
fld = ComplexField(name="foo", fields=[], collection=True)
3636
assert fld.name == "foo"
37-
assert fld.type == edm.Collection(edm.ComplexType)
37+
assert fld.type == SearchFieldDataType.Collection(SearchFieldDataType.ComplexType)
3838

3939
assert fld.sortable is None
4040
assert fld.facetable is None
@@ -47,9 +47,9 @@ def test_collection(self):
4747

4848
class TestSimplexField(object):
4949
def test_defaults(self):
50-
fld = SimpleField(name="foo", type=edm.Double)
50+
fld = SimpleField(name="foo", type=SearchFieldDataType.Double)
5151
assert fld.name == "foo"
52-
assert fld.type == edm.Double
52+
assert fld.type == SearchFieldDataType.Double
5353
assert fld.retrievable == True
5454
assert fld.sortable == False
5555
assert fld.facetable == False
@@ -63,9 +63,9 @@ def test_defaults(self):
6363

6464
class TestSearchableField(object):
6565
def test_defaults(self):
66-
fld = SearchableField(name="foo", type=edm.Collection(edm.String))
66+
fld = SearchableField(name="foo", type=SearchFieldDataType.Collection(SearchFieldDataType.String))
6767
assert fld.name == "foo"
68-
assert fld.type == edm.Collection(edm.String)
68+
assert fld.type == SearchFieldDataType.Collection(SearchFieldDataType.String)
6969
assert fld.retrievable == True
7070
assert fld.sortable == False
7171
assert fld.facetable == False

sdk/search/azure-search-documents/tests/test_service_live.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
SearchIndexerDataContainer,
3232
SynonymMap,
3333
SimpleField,
34-
edm
34+
SearchFieldDataType
3535
)
3636
from azure.search.documents.indexes import SearchIndexClient, SearchIndexerClient
3737

@@ -143,8 +143,8 @@ def test_delete_indexes_if_unchanged(self, api_key, endpoint, index_name, **kwar
143143
def test_create_index(self, api_key, endpoint, index_name, **kwargs):
144144
name = "hotels"
145145
fields = [
146-
SimpleField(name="hotelId", type=edm.String, key=True),
147-
SimpleField(name="baseRate", type=edm.Double)
146+
SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True),
147+
SimpleField(name="baseRate", type=SearchFieldDataType.Double)
148148
]
149149
scoring_profile = ScoringProfile(
150150
name="MyProfile"
@@ -169,8 +169,8 @@ def test_create_index(self, api_key, endpoint, index_name, **kwargs):
169169
def test_create_or_update_index(self, api_key, endpoint, index_name, **kwargs):
170170
name = "hotels"
171171
fields = [
172-
SimpleField(name="hotelId", type=edm.String, key=True),
173-
SimpleField(name="baseRate", type=edm.Double)
172+
SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True),
173+
SimpleField(name="baseRate", type=SearchFieldDataType.Double)
174174
]
175175
cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60)
176176
scoring_profiles = []

0 commit comments

Comments
 (0)