Skip to content

Commit 772b626

Browse files
authored
Add CategorizeText aggregation (elastic#1589)
1 parent acd63a8 commit 772b626

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

elasticsearch_dsl/aggs.py

+4
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ class MultiTerms(Bucket):
309309
name = "multi_terms"
310310

311311

312+
class CategorizeText(Bucket):
313+
name = "categorize_text"
314+
315+
312316
# metric aggregations
313317
class TopHits(Agg):
314318
name = "top_hits"

tests/test_aggs.py

+17
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,23 @@ def test_multi_terms_aggregation():
342342
} == a.to_dict()
343343

344344

345+
def test_categorize_text_aggregation():
346+
a = aggs.CategorizeText(
347+
field="tags",
348+
categorization_filters=["\\w+\\_\\d{3}"],
349+
max_matched_tokens=2,
350+
similarity_threshold=30,
351+
)
352+
assert {
353+
"categorize_text": {
354+
"field": "tags",
355+
"categorization_filters": ["\\w+\\_\\d{3}"],
356+
"max_matched_tokens": 2,
357+
"similarity_threshold": 30,
358+
}
359+
} == a.to_dict()
360+
361+
345362
def test_median_absolute_deviation_aggregation():
346363
a = aggs.MedianAbsoluteDeviation(field="rating")
347364

0 commit comments

Comments
 (0)