feat: aggs remove is_text field

This commit is contained in:
yim7
2022-09-22 15:29:50 +08:00
parent 7ab7581625
commit cb6ab84d51
5 changed files with 573 additions and 57 deletions

View File

@@ -67,7 +67,7 @@ with SearchSession() as session:
## exclude
``` python
{'bool': {'must_not': [{'match_phrase': {'method': 'get'}}, {'match_phrase': {'path': '/login'}}], 'should': [], 'filter': []}}
# {'bool': {'must_not': [{'match_phrase': {'method': 'get'}}, {'match_phrase': {'path': '/login'}}], 'should': [], 'filter': []}}
with SearchSession() as session:
result = (
session.select(UserLog)
@@ -92,12 +92,15 @@ with SearchSession() as session:
```
## aggregations
group by path and count unique remote_ip
group by path and count unique remote_ip.
``` python
with SearchSession() as session:
# aggregate text must need use a keyword field instead
# request_timeout argument will be passed on to the opensearch-py
result = (
session.select(UserLog)
.aggregate(Terms('path').nested(Cardinality('remote_ip')))
.aggregate(Terms('path.keyword').nested(Cardinality('remote_ip,keyword')), request_timeout=300)
)
print(result)
# result -> {'path': 1, 'path2': 2}