Skip to content

Commit 7e485b9

Browse files
Telomerazgithub-actions[bot]
authored andcommitted
Add CategorizeText aggregation (#1589)
(cherry picked from commit 772b626)
1 parent e30129d commit 7e485b9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

elasticsearch_dsl/aggs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ class MultiTerms(Bucket):
297297
name = "multi_terms"
298298

299299

300+
class CategorizeText(Bucket):
301+
name = "categorize_text"
302+
303+
300304
# metric aggregations
301305
class TopHits(Agg):
302306
name = "top_hits"

tests/test_aggs.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,23 @@ def test_multi_terms_aggregation():
312312
} == a.to_dict()
313313

314314

315+
def test_categorize_text_aggregation():
316+
a = aggs.CategorizeText(
317+
field="tags",
318+
categorization_filters=["\\w+\\_\\d{3}"],
319+
max_matched_tokens=2,
320+
similarity_threshold=30,
321+
)
322+
assert {
323+
"categorize_text": {
324+
"field": "tags",
325+
"categorization_filters": ["\\w+\\_\\d{3}"],
326+
"max_matched_tokens": 2,
327+
"similarity_threshold": 30,
328+
}
329+
} == a.to_dict()
330+
331+
315332
def test_median_absolute_deviation_aggregation():
316333
a = aggs.MedianAbsoluteDeviation(field="rating")
317334

0 commit comments

Comments
 (0)