Skip to content

Commit

Permalink
Accept meta fields mappings with or without leading _
Browse files Browse the repository at this point in the history
  • Loading branch information
honzakral committed Apr 23, 2015
1 parent ec36d25 commit 493c27c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion elasticsearch_dsl/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, name, bases, attrs):
# add all the mappings for meta fields
for name in dir(meta):
if isinstance(getattr(meta, name, None), MetaField):
self.mapping.meta('_' + name if not name.startswith('_') else name, **getattr(meta, name))
self.mapping.meta(name, **getattr(meta, name))

# document inheritance - include the fields from parents' mappings and
# index/using values
Expand Down
3 changes: 3 additions & 0 deletions elasticsearch_dsl/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def field(self, *args, **kwargs):
return self

def meta(self, name, **kwargs):
if not name.startswith('_'):
name = '_' + name

if not kwargs:
if name in self._meta:
del self._meta[name]
Expand Down

0 comments on commit 493c27c

Please sign in to comment.