diff --git a/elasticsearch_dsl/__init__.py b/elasticsearch_dsl/__init__.py index facddf7bd..a1d2ab8b2 100644 --- a/elasticsearch_dsl/__init__.py +++ b/elasticsearch_dsl/__init__.py @@ -66,6 +66,7 @@ Percolator, RangeField, RankFeature, + RankFeatures, ScaledFloat, SearchAsYouType, Short, @@ -139,6 +140,7 @@ "RangeFacet", "RangeField", "RankFeature", + "RankFeatures", "SF", "ScaledFloat", "Search", diff --git a/elasticsearch_dsl/field.py b/elasticsearch_dsl/field.py index 6e79b4077..06a10f2a2 100644 --- a/elasticsearch_dsl/field.py +++ b/elasticsearch_dsl/field.py @@ -378,6 +378,10 @@ class RankFeature(Float): name = "rank_feature" +class RankFeatures(Field): + name = "rank_features" + + class Integer(Field): name = "integer" _coerce = True diff --git a/tests/test_field.py b/tests/test_field.py index 2e8ec9689..8bc8d6f03 100644 --- a/tests/test_field.py +++ b/tests/test_field.py @@ -177,6 +177,11 @@ def test_constant_keyword(): assert f.to_dict() == {"type": "constant_keyword"} +def test_rank_features(): + f = field.RankFeatures() + assert f.to_dict() == {"type": "rank_features"} + + def test_object_dynamic_values(): for dynamic in True, False, "strict": f = field.Object(dynamic=dynamic) diff --git a/tests/test_integration/test_document.py b/tests/test_integration/test_document.py index 298787d87..a25279abe 100644 --- a/tests/test_integration/test_document.py +++ b/tests/test_integration/test_document.py @@ -37,6 +37,7 @@ Nested, Object, Q, + RankFeatures, Text, analyzer, ) @@ -52,6 +53,7 @@ class User(InnerDoc): class Wiki(Document): owner = Object(User) views = Long() + ranked = RankFeatures() class Index: name = "test-wiki" @@ -204,7 +206,11 @@ def test_nested_top_hits_are_wrapped_properly(pull_request): def test_update_object_field(write_client): Wiki.init() - w = Wiki(owner=User(name="Honza Kral"), _id="elasticsearch-py") + w = Wiki( + owner=User(name="Honza Kral"), + _id="elasticsearch-py", + ranked={"test1": 0.1, "topic2": 0.2}, + ) w.save() assert "updated" == w.update(owner=[{"name": "Honza"}, {"name": "Nick"}]) @@ -215,6 +221,8 @@ def test_update_object_field(write_client): assert w.owner[0].name == "Honza" assert w.owner[1].name == "Nick" + assert w.ranked == {"test1": 0.1, "topic2": 0.2} + def test_update_script(write_client): Wiki.init()