Skip to content

Commit

Permalink
Add CategorizeText aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
Telomeraz committed May 18, 2022
1 parent 477eb08 commit 3f7fac1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions elasticsearch_dsl/aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ class MultiTerms(Bucket):
name = "multi_terms"


class CategorizeText(Bucket):
name = "categorize_text"


# metric aggregations
class TopHits(Agg):
name = "top_hits"
Expand Down
17 changes: 17 additions & 0 deletions tests/test_aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,23 @@ def test_multi_terms_aggregation():
} == a.to_dict()


def test_categorize_text_aggregation():
a = aggs.CategorizeText(
field="tags",
categorization_filters=["\\w+\\_\\d{3}"],
max_matched_tokens=2,
similarity_threshold=30,
)
assert {
"categorize_text": {
"field": "tags",
"categorization_filters": ["\\w+\\_\\d{3}"],
"max_matched_tokens": 2,
"similarity_threshold": 30,
}
} == a.to_dict()


def test_median_absolute_deviation_aggregation():
a = aggs.MedianAbsoluteDeviation(field="rating")

Expand Down

0 comments on commit 3f7fac1

Please sign in to comment.