Skip to content

Commit d177fa3

Browse files
rename new index template to composable index template
1 parent 5d5b68f commit d177fa3

File tree

12 files changed

+35
-25
lines changed

12 files changed

+35
-25
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ venv
1717

1818
# sample code for GitHub issues
1919
issues
20+
.direnv
21+
.envrc

elasticsearch_dsl/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@
8080
)
8181
from .function import SF
8282
from .index import (
83+
AsyncComposableIndexTemplate,
8384
AsyncIndex,
8485
AsyncIndexTemplate,
85-
AsyncNewIndexTemplate,
86+
ComposableIndexTemplate,
8687
Index,
8788
IndexTemplate,
88-
NewIndexTemplate,
8989
)
9090
from .mapping import AsyncMapping, Mapping
9191
from .query import Q, Query
@@ -109,14 +109,14 @@
109109
"A",
110110
"Agg",
111111
"AggResponse",
112+
"AsyncComposableIndexTemplate",
112113
"AsyncDocument",
113114
"AsyncEmptySearch",
114115
"AsyncFacetedSearch",
115116
"AsyncIndex",
116117
"AsyncIndexTemplate",
117118
"AsyncMapping",
118119
"AsyncMultiSearch",
119-
"AsyncNewIndexTemplate",
120120
"AsyncSearch",
121121
"AsyncUpdateByQuery",
122122
"AttrDict",
@@ -125,6 +125,7 @@
125125
"Boolean",
126126
"Byte",
127127
"Completion",
128+
"ComposableIndexTemplate",
128129
"ConstantKeyword",
129130
"CustomField",
130131
"Date",
@@ -166,7 +167,6 @@
166167
"Murmur3",
167168
"Nested",
168169
"NestedFacet",
169-
"NewIndexTemplate",
170170
"Object",
171171
"Percolator",
172172
"Q",

elasticsearch_dsl/_async/index.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async def save(
7373
)
7474

7575

76-
class AsyncNewIndexTemplate:
76+
class AsyncComposableIndexTemplate:
7777
def __init__(
7878
self,
7979
name: str,
@@ -150,16 +150,16 @@ def as_template(
150150
template_name, pattern or self._name, index=self, order=order
151151
)
152152

153-
def as_new_template(
153+
def as_composable_template(
154154
self,
155155
template_name: str,
156156
pattern: Optional[str] = None,
157157
priority: Optional[int] = None,
158-
) -> AsyncNewIndexTemplate:
158+
) -> AsyncComposableIndexTemplate:
159159
# TODO: should we allow pattern to be a top-level arg?
160160
# or maybe have an IndexPattern that allows for it and have
161161
# Document._index be that?
162-
return AsyncNewIndexTemplate(
162+
return AsyncComposableIndexTemplate(
163163
template_name, pattern or self._name, index=self, priority=priority
164164
)
165165

elasticsearch_dsl/_sync/index.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def save(self, using: Optional[UsingType] = None) -> "ObjectApiResponse[Any]":
6969
return es.indices.put_template(name=self._template_name, body=self.to_dict())
7070

7171

72-
class NewIndexTemplate:
72+
class ComposableIndexTemplate:
7373
def __init__(
7474
self,
7575
name: str,
@@ -140,16 +140,16 @@ def as_template(
140140
template_name, pattern or self._name, index=self, order=order
141141
)
142142

143-
def as_new_template(
143+
def as_composable_template(
144144
self,
145145
template_name: str,
146146
pattern: Optional[str] = None,
147147
priority: Optional[int] = None,
148-
) -> NewIndexTemplate:
148+
) -> ComposableIndexTemplate:
149149
# TODO: should we allow pattern to be a top-level arg?
150150
# or maybe have an IndexPattern that allows for it and have
151151
# Document._index be that?
152-
return NewIndexTemplate(
152+
return ComposableIndexTemplate(
153153
template_name, pattern or self._name, index=self, priority=priority
154154
)
155155

elasticsearch_dsl/index.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
# under the License.
1717

1818
from ._async.index import ( # noqa: F401
19+
AsyncComposableIndexTemplate,
1920
AsyncIndex,
2021
AsyncIndexTemplate,
21-
AsyncNewIndexTemplate,
2222
)
23-
from ._sync.index import Index, IndexTemplate, NewIndexTemplate # noqa: F401
23+
from ._sync.index import ComposableIndexTemplate, Index, IndexTemplate # noqa: F401

examples/alias_migration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ def setup() -> None:
8282
deploy.
8383
"""
8484
# create an index template
85-
index_template = BlogPost._index.as_new_template(ALIAS, PATTERN, priority=PRIORITY)
85+
index_template = BlogPost._index.as_composable_template(
86+
ALIAS, PATTERN, priority=PRIORITY
87+
)
8688
# upload the template into elasticsearch
8789
# potentially overriding the one already there
8890
index_template.save()

examples/async/alias_migration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ async def setup() -> None:
8383
deploy.
8484
"""
8585
# create an index template
86-
index_template = BlogPost._index.as_new_template(ALIAS, PATTERN, priority=PRIORITY)
86+
index_template = BlogPost._index.as_composable_template(
87+
ALIAS, PATTERN, priority=PRIORITY
88+
)
8789
# upload the template into elasticsearch
8890
# potentially overriding the one already there
8991
await index_template.save()

examples/async/parent_child.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ async def save(self, **kwargs: Any) -> None: # type: ignore[override]
226226

227227
async def setup() -> None:
228228
"""Create an IndexTemplate and save it into elasticsearch."""
229-
index_template = Post._index.as_new_template("base", priority=100)
229+
index_template = Post._index.as_composable_template("base", priority=100)
230230
await index_template.save()
231231

232232

examples/parent_child.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def save(self, **kwargs: Any) -> None: # type: ignore[override]
225225

226226
def setup() -> None:
227227
"""Create an IndexTemplate and save it into elasticsearch."""
228-
index_template = Post._index.as_new_template("base", priority=100)
228+
index_template = Post._index.as_composable_template("base", priority=100)
229229
index_template.save()
230230

231231

tests/test_integration/_async/test_index.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
from elasticsearch import AsyncElasticsearch
2020

2121
from elasticsearch_dsl import (
22+
AsyncComposableIndexTemplate,
2223
AsyncDocument,
2324
AsyncIndex,
2425
AsyncIndexTemplate,
25-
AsyncNewIndexTemplate,
2626
Date,
2727
Text,
2828
analysis,
@@ -57,8 +57,10 @@ async def test_index_template_works(async_write_client: AsyncElasticsearch) -> N
5757

5858

5959
@pytest.mark.asyncio
60-
async def test_new_index_template_works(async_write_client: AsyncElasticsearch) -> None:
61-
it = AsyncNewIndexTemplate("test-template", "test-*")
60+
async def test_composable_index_template_works(
61+
async_write_client: AsyncElasticsearch,
62+
) -> None:
63+
it = AsyncComposableIndexTemplate("test-template", "test-*")
6264
it.document(Post)
6365
it.settings(number_of_replicas=0, number_of_shards=1)
6466
await it.save()

tests/test_integration/_sync/test_index.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
from elasticsearch import Elasticsearch
2020

2121
from elasticsearch_dsl import (
22+
ComposableIndexTemplate,
2223
Date,
2324
Document,
2425
Index,
2526
IndexTemplate,
26-
NewIndexTemplate,
2727
Text,
2828
analysis,
2929
)
@@ -57,8 +57,10 @@ def test_index_template_works(write_client: Elasticsearch) -> None:
5757

5858

5959
@pytest.mark.sync
60-
def test_new_index_template_works(write_client: Elasticsearch) -> None:
61-
it = NewIndexTemplate("test-template", "test-*")
60+
def test_composable_index_template_works(
61+
write_client: Elasticsearch,
62+
) -> None:
63+
it = ComposableIndexTemplate("test-template", "test-*")
6264
it.document(Post)
6365
it.settings(number_of_replicas=0, number_of_shards=1)
6466
it.save()

utils/run-unasync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def main(check=False):
5757
"AsyncIndexMeta": "IndexMeta",
5858
"AsyncIndexTemplate": "IndexTemplate",
5959
"AsyncIndex": "Index",
60-
"AsyncNewIndexTemplate": "NewIndexTemplate",
60+
"AsyncComposableIndexTemplate": "ComposableIndexTemplate",
6161
"AsyncUpdateByQuery": "UpdateByQuery",
6262
"AsyncMapping": "Mapping",
6363
"AsyncFacetedSearch": "FacetedSearch",

0 commit comments

Comments
 (0)