Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'constant_keyword' #1456

Merged
merged 2 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions elasticsearch_dsl/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ class Keyword(Field):
name = "keyword"


class ConstantKeyword(Keyword):
name = "constant_keyword"


class Boolean(Field):
name = "boolean"
_coerce = True
Expand Down
5 changes: 5 additions & 0 deletions tests/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ def test_binary():
assert f.deserialize(None) is None


def test_constant_keyword():
f = field.ConstantKeyword()
assert f.to_dict() == {"type": "constant_keyword"}


def test_object_dynamic_values():
for dynamic in True, False, "strict":
f = field.Object(dynamic=dynamic)
Expand Down