Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor aggregations result handling #555

Merged
merged 3 commits into from
Jan 26, 2016
Merged

Refactor aggregations result handling #555

merged 3 commits into from
Jan 26, 2016

Conversation

mvar
Copy link
Member

@mvar mvar commented Jan 19, 2016

Main changes:

Quicker properties access:

Now you can directly access aggregation properties using array access syntax.

Before:

$result->getAggregation('range_agg')->getValue()['min'];

After:

$result->getAggregation('range_agg')['min'];

Logically separated buckets

From now on all aggregations are returned as instance of ValueAggregation (previously bucketed aggregations were returned as iterator of buckets). This means all aggregation properties can be reached the same way as with metric aggregations. You still can iterate over buckets by using aggregation itself as iterator. You can get array of buckets by calling getBuckets().

Before:

$buckets = $result->getAggregation($name);

After:

$fooValue = $result->getAggregation($name)['foo_value'];
$buckets = $result->getAggregation($name)->getBuckets();

Closes #554

@mvar mvar added the qa label Jan 19, 2016
@saimaz
Copy link
Member

saimaz commented Jan 21, 2016

Lets release ElasticsearchDSL 2.0 and this will be a way to go.

@mvar mvar changed the title [WIP] Refactor aggregations result handling Refactor aggregations result handling Jan 22, 2016
@mvar
Copy link
Member Author

mvar commented Jan 22, 2016

Updated code to work with DSL 2.0 (master branch currently).

This PR is ready to merge, but before merging we should discuss about naming. I don't like neither ValueAggregation nor AggregationValue.

@saimaz
Copy link
Member

saimaz commented Jan 22, 2016

AggregationValue seems a good choice, otherwise the name will be inaccurate.

mvar added a commit that referenced this pull request Jan 26, 2016
Refactor aggregations result handling
@mvar mvar merged commit 0cfdcdb into ongr-io:master Jan 26, 2016
@mvar mvar removed the qa label Jan 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants