-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aggregations: support for pipeline aggs and filter (#1296)
* Aggregations: support for pipeline aggs and filter Both can be defined in a container. Only bucket selector pipeline aggregation for now.
- Loading branch information
1 parent
d014740
commit 32b86e5
Showing
25 changed files
with
953 additions
and
97 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
50 changes: 50 additions & 0 deletions
50
...e-core/Search/Adapter/Elasticsuite/Request/Aggregation/PipelineBuilder/BucketSelector.php
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,50 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Richard BAYET <richard.bayet@smile.fr> | ||
* @copyright 2019 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Aggregation\PipelineBuilder; | ||
|
||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Aggregation\PipelineBuilderInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\PipelineInterface; | ||
|
||
/** | ||
* Build a bucket selector ES pipeline aggregation. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
*/ | ||
class BucketSelector implements PipelineBuilderInterface | ||
{ | ||
/** | ||
* Build the pipeline aggregation. | ||
* | ||
* @param PipelineInterface $pipeline Bucket selector pipeline. | ||
* | ||
* @return array | ||
*/ | ||
public function buildPipeline(PipelineInterface $pipeline) | ||
{ | ||
if ($pipeline->getType() !== PipelineInterface::TYPE_BUCKET_SELECTOR) { | ||
throw new \InvalidArgumentException("Query builder : invalid aggregation type {$pipeline->getType()}."); | ||
} | ||
|
||
$aggParams = [ | ||
'buckets_path' => $pipeline->getBucketsPath(), | ||
'script' => $pipeline->getScript(), | ||
'gap_policy' => $pipeline->getGapPolicy(), | ||
]; | ||
|
||
return ['bucket_selector' => $aggParams]; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...icsuite-core/Search/Adapter/Elasticsuite/Request/Aggregation/PipelineBuilderInterface.php
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 | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Richard BAYET <richard.bayet@smile.fr> | ||
* @copyright 2019 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Aggregation; | ||
|
||
use Smile\ElasticsuiteCore\Search\Request\PipelineInterface; | ||
|
||
/** | ||
* Build Elasticsearch pipeline aggregation from search request PipelineInterface. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
*/ | ||
interface PipelineBuilderInterface | ||
{ | ||
/** | ||
* Build the ES aggregation from a search request pipeline. | ||
* | ||
* @param PipelineInterface $pipeline Pipeline to be built. | ||
* | ||
* @return array | ||
*/ | ||
public function buildPipeline(PipelineInterface $pipeline); | ||
} |
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.