Skip to content

Commit

Permalink
Merge pull request #22 from designmynight/21-min-doc-count
Browse files Browse the repository at this point in the history
fix: #21, can now specify min_doc_count and extended_bounds
  • Loading branch information
danjohnson95 authored Feb 13, 2018
2 parents dc0dabf + 3097414 commit 45e4790
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/DesignMyNight/Elasticsearch/QueryGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,21 @@ protected function compileDateHistogramAggregation(array $aggregation): array
]
];

if ( is_array($aggregation['args']) && isset($aggregation['args']['interval']) ){
$compiled['date_histogram']['interval'] = $aggregation['args']['interval'];
if ( is_array($aggregation['args']) ){
if ( isset($aggregation['args']['interval']) ){
$compiled['date_histogram']['interval'] = $aggregation['args']['interval'];
}

if ( isset($aggregation['args']['min_doc_count']) ){
$compiled['date_histogram']['min_doc_count'] = $aggregation['args']['min_doc_count'];
}

if ( isset($aggregation['args']['extended_bounds']) && is_array($aggregation['args']['extended_bounds']) ){
$compiled['date_histogram']['extended_bounds'] = [];
$compiled['date_histogram']['extended_bounds']['min'] = $this->convertDateTime($aggregation['args']['extended_bounds'][0]);
$compiled['date_histogram']['extended_bounds']['max'] = $this->convertDateTime($aggregation['args']['extended_bounds'][1]);
}

}

return $compiled;
Expand Down

0 comments on commit 45e4790

Please sign in to comment.