-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from alk-lbinet/clarifications
Clarifications
- Loading branch information
Showing
23 changed files
with
396 additions
and
481 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .query import * | ||
from .aggs import * | ||
from .mapping import * | ||
from .query import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .bucket import * | ||
from .composite import * | ||
from .metric import * | ||
from .pipeline import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from .abstract import BucketAggNode | ||
|
||
|
||
class Composite(BucketAggNode): | ||
def __init__(self, sources, size=None, after_key=None, meta=None, **body): | ||
"""https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html | ||
:param sources: | ||
:param size: | ||
:param after_key: | ||
:param meta: | ||
:param body: | ||
""" | ||
self._sources = sources | ||
self._size = size | ||
self._after_key = after_key | ||
self._children = body.pop("aggs", None) or body.pop("aggregations", None) or {} | ||
if size is not None: | ||
body["size"] = size | ||
if after_key is not None: | ||
body["after_key"] = after_key | ||
super(Composite, self).__init__(meta=meta, sources=sources, **body) | ||
|
||
def extract_buckets(self, response_value): | ||
for bucket in response_value["buckets"]: | ||
yield bucket["key"], bucket | ||
|
||
def get_filter(self, key): | ||
"""In composite aggregation, key is a map, source name -> value""" | ||
if not key: | ||
return | ||
conditions = [] | ||
for source in self._sources: | ||
name, agg = source.popitem() | ||
if name not in key: | ||
continue | ||
agg_type, agg_body = source.popitem() | ||
agg_instance = self._get_dsl_class(agg_type)(**agg_body) | ||
conditions.append(agg_instance.get_filter(key=key[name])) | ||
if not conditions: | ||
return | ||
return {"bool": {"filter": conditions}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.