Skip to content

Commit

Permalink
Add CategorizeText aggregation (#1589)
Browse files Browse the repository at this point in the history
  • Loading branch information
Telomeraz committed Apr 15, 2024
1 parent acd63a8 commit 772b626
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 @@ -309,6 +309,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 @@ -342,6 +342,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 772b626

Please sign in to comment.