-
Notifications
You must be signed in to change notification settings - Fork 729
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract setting gap policy to trait (#2023)
The purpose of the introduced interface is to avoid typos by using constants for options. That said, it also fixed the typo on Serial differencing aggregation, which is/was also a typo in the official docs. See elastic/elasticsearch#80893
- Loading branch information
Showing
12 changed files
with
79 additions
and
85 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
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,36 @@ | ||
<?php | ||
|
||
namespace Elastica\Aggregation; | ||
|
||
use Elastica\Aggregation\Traits\GapPolicyTrait; | ||
|
||
/** | ||
* Dealing with gaps in the data. | ||
* | ||
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline.html#gap-policy | ||
* @see GapPolicyTrait | ||
*/ | ||
interface GapPolicyInterface | ||
{ | ||
/** | ||
* Treats missing data as if the bucket does not exist. It will skip the bucket and continue calculating using the next available value. | ||
*/ | ||
public const SKIP = 'skip'; | ||
|
||
/** | ||
* Will replace missing values with a zero (0) and pipeline aggregation computation will proceed as normal. | ||
*/ | ||
public const INSERT_ZEROS = 'insert_zeros'; | ||
|
||
/** | ||
* Is similar to skip, except if the metric provides a non-null, non-NaN value this value is used, otherwise the empty bucket is skipped. | ||
*/ | ||
public const KEEP_VALUES = 'keep_values'; | ||
|
||
/** | ||
* Set the gap policy for this aggregation. | ||
* | ||
* @return $this | ||
*/ | ||
public function setGapPolicy(string $gapPolicy); | ||
} |
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
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,16 @@ | ||
<?php | ||
|
||
namespace Elastica\Aggregation\Traits; | ||
|
||
use Elastica\Aggregation\GapPolicyInterface; | ||
|
||
/** | ||
* @see GapPolicyInterface | ||
*/ | ||
trait GapPolicyTrait | ||
{ | ||
public function setGapPolicy(string $gapPolicy = GapPolicyInterface::SKIP): self | ||
{ | ||
return $this->setParam('gap_policy', $gapPolicy); | ||
} | ||
} |