Skip to content

Commit 3f7fac1

Browse files
committed
Add CategorizeText aggregation
1 parent 477eb08 commit 3f7fac1

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
@@ -300,6 +300,10 @@ class MultiTerms(Bucket):
300300
name = "multi_terms"
301301

302302

303+
class CategorizeText(Bucket):
304+
name = "categorize_text"
305+
306+
303307
# metric aggregations
304308
class TopHits(Agg):
305309
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)