Skip to content

Commit a15b591

Browse files
committed
updated docs for new Nested syntax
1 parent 3ce0c90 commit a15b591

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

docs/persistence.rst

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ The mapping definition follows a similar pattern to the query dsl:
2525
m.field('category', 'text', fields={'raw': Keyword()})
2626
2727
# you can also create a field manually
28-
comment = Nested()
29-
comment.field('author', Text())
30-
comment.field('created_at', Date())
28+
comment = Nested(
29+
properties={
30+
'author': Text(),
31+
'created_at': Date()
32+
})
3133
3234
# and attach it to the mapping
3335
m.field('comments', comment)
@@ -109,15 +111,19 @@ If you want to create a model-like wrapper around your documents, use the
109111
110112
from datetime import datetime
111113
from elasticsearch_dsl import DocType, Date, Nested, Boolean, \
112-
analyzer, InnerObjectWrapper, Completion, Keyword, Text
114+
analyzer, InnerDoc, Completion, Keyword, Text
113115
114116
html_strip = analyzer('html_strip',
115117
tokenizer="standard",
116118
filter=["standard", "lowercase", "stop", "snowball"],
117119
char_filter=["html_strip"]
118120
)
119121
120-
class Comment(InnerObjectWrapper):
122+
class Comment(InnerDoc):
123+
author = Text(fields={'raw': Keyword()})
124+
content = Text(analyzer='snowball')
125+
created_at = Date()
126+
121127
def age(self):
122128
return datetime.now() - self.created_at
123129
@@ -131,14 +137,7 @@ If you want to create a model-like wrapper around your documents, use the
131137
fields={'raw': Keyword()}
132138
)
133139
134-
comments = Nested(
135-
doc_class=Comment,
136-
properties={
137-
'author': Text(fields={'raw': Keyword()}),
138-
'content': Text(analyzer='snowball'),
139-
'created_at': Date()
140-
}
141-
)
140+
comments = Nested(Comment)
142141
143142
class Meta:
144143
index = 'blog'

0 commit comments

Comments
 (0)