-
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.
- Loading branch information
1 parent
600627d
commit 52f773a
Showing
20 changed files
with
1,455 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...asticsuite-core/Search/Adapter/Elasticsuite/Request/Query/Builder/Span/SpanContaining.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,47 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
* @copyright 2023 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\Span; | ||
|
||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\AbstractComplexBuilder; | ||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\BuilderInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\Query\SpanQueryInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\QueryInterface; | ||
|
||
/** | ||
* Build an ES span_containing query. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
*/ | ||
class SpanContaining extends AbstractComplexBuilder implements BuilderInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function buildQuery(QueryInterface $query) | ||
{ | ||
if ($query->getType() !== SpanQueryInterface::TYPE_SPAN_CONTAINING) { | ||
throw new \InvalidArgumentException("Query builder : invalid query type {$query->getType()}"); | ||
} | ||
|
||
return [ | ||
'span_containing' => [ | ||
'little' => $this->parentBuilder->buildQuery($query->getLittle()), | ||
'big' => $this->parentBuilder->buildQuery($query->getBig()), | ||
], | ||
]; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...ticsuite-core/Search/Adapter/Elasticsuite/Request/Query/Builder/Span/SpanFieldMasking.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,47 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
* @copyright 2023 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\Span; | ||
|
||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\AbstractComplexBuilder; | ||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\BuilderInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\Query\SpanQueryInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\QueryInterface; | ||
|
||
/** | ||
* Build an ES span_field_masking query. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
*/ | ||
class SpanFieldMasking extends AbstractComplexBuilder implements BuilderInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function buildQuery(QueryInterface $query) | ||
{ | ||
if ($query->getType() !== SpanQueryInterface::TYPE_SPAN_FIELD_MASKING) { | ||
throw new \InvalidArgumentException("Query builder : invalid query type {$query->getType()}"); | ||
} | ||
|
||
return [ | ||
'span_field_masking' => [ | ||
'query' => $this->parentBuilder->buildQuery($query->getQuery()), | ||
'field' => $query->getField(), | ||
], | ||
]; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...le-elasticsuite-core/Search/Adapter/Elasticsuite/Request/Query/Builder/Span/SpanFirst.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,47 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
* @copyright 2023 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\Span; | ||
|
||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\AbstractComplexBuilder; | ||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\BuilderInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\Query\SpanQueryInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\QueryInterface; | ||
|
||
/** | ||
* Build an ES span_first query. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
*/ | ||
class SpanFirst extends AbstractComplexBuilder implements BuilderInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function buildQuery(QueryInterface $query) | ||
{ | ||
if ($query->getType() !== SpanQueryInterface::TYPE_SPAN_FIRST) { | ||
throw new \InvalidArgumentException("Query builder : invalid query type {$query->getType()}"); | ||
} | ||
|
||
return [ | ||
'span_first' => [ | ||
'match' => $this->parentBuilder->buildQuery($query->getMatch()), | ||
'end' => $query->getEnd(), | ||
], | ||
]; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...lasticsuite-core/Search/Adapter/Elasticsuite/Request/Query/Builder/Span/SpanMultiTerm.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,46 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
* @copyright 2023 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\Span; | ||
|
||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\AbstractComplexBuilder; | ||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\BuilderInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\Query\SpanQueryInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\QueryInterface; | ||
|
||
/** | ||
* Build an ES span_multi query. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
*/ | ||
class SpanMultiTerm extends AbstractComplexBuilder implements BuilderInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function buildQuery(QueryInterface $query) | ||
{ | ||
if ($query->getType() !== SpanQueryInterface::TYPE_SPAN_MULTI_TERM) { | ||
throw new \InvalidArgumentException("Query builder : invalid query type {$query->getType()}"); | ||
} | ||
|
||
return [ | ||
'span_multi' => [ | ||
'match' => $this->parentBuilder->buildQuery($query->getMatch()), | ||
], | ||
]; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...ule-elasticsuite-core/Search/Adapter/Elasticsuite/Request/Query/Builder/Span/SpanNear.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,49 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
* @copyright 2023 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\Span; | ||
|
||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\BuilderInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\Query\SpanQueryInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\QueryInterface; | ||
|
||
/** | ||
* Build an ES span_near query. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
*/ | ||
class SpanNear implements BuilderInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function buildQuery(QueryInterface $query) | ||
{ | ||
if ($query->getType() !== SpanQueryInterface::TYPE_SPAN_NEAR) { | ||
throw new \InvalidArgumentException("Query builder : invalid query type {$query->getType()}"); | ||
} | ||
|
||
$clauses = array_map([$this->parentBuilder, 'buildQuery'], $query->getClauses()); | ||
|
||
return [ | ||
'span_near' => [ | ||
'clauses' => array_filter($clauses), | ||
'slop' => $query->getSlop(), | ||
'in_order' => $query->getInOrder(), | ||
], | ||
]; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...dule-elasticsuite-core/Search/Adapter/Elasticsuite/Request/Query/Builder/Span/SpanNot.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,47 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
* @copyright 2023 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\Span; | ||
|
||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\AbstractComplexBuilder; | ||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\BuilderInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\Query\SpanQueryInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\QueryInterface; | ||
|
||
/** | ||
* Build an ES span_not query. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
*/ | ||
class SpanNot extends AbstractComplexBuilder implements BuilderInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function buildQuery(QueryInterface $query) | ||
{ | ||
if ($query->getType() !== SpanQueryInterface::TYPE_SPAN_NOT) { | ||
throw new \InvalidArgumentException("Query builder : invalid query type {$query->getType()}"); | ||
} | ||
|
||
return [ | ||
'span_not' => [ | ||
'include' => $this->parentBuilder->buildQuery($query->getInclude()), | ||
'exclude' => $this->parentBuilder->buildQuery($query->getExclude()), | ||
], | ||
]; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...odule-elasticsuite-core/Search/Adapter/Elasticsuite/Request/Query/Builder/Span/SpanOr.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,47 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
* @copyright 2023 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\Span; | ||
|
||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\BuilderInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\Query\SpanQueryInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\QueryInterface; | ||
|
||
/** | ||
* Build an ES span_or query. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
*/ | ||
class SpanOr implements BuilderInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function buildQuery(QueryInterface $query) | ||
{ | ||
if ($query->getType() !== SpanQueryInterface::TYPE_SPAN_OR) { | ||
throw new \InvalidArgumentException("Query builder : invalid query type {$query->getType()}"); | ||
} | ||
|
||
$clauses = array_map([$this->parentBuilder, 'buildQuery'], $query->getClauses()); | ||
|
||
return [ | ||
'span_or' => [ | ||
'clauses' => array_filter($clauses), | ||
], | ||
]; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...ule-elasticsuite-core/Search/Adapter/Elasticsuite/Request/Query/Builder/Span/SpanTerm.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,52 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
* @copyright 2023 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\Builder\Span; | ||
|
||
use Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Query\BuilderInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\Query\SpanQueryInterface; | ||
use Smile\ElasticsuiteCore\Search\Request\QueryInterface; | ||
|
||
/** | ||
* Build an ES span_term query. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCore | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
*/ | ||
class SpanTerm implements BuilderInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function buildQuery(QueryInterface $query) | ||
{ | ||
if ($query->getType() !== SpanQueryInterface::TYPE_SPAN_TERM) { | ||
throw new \InvalidArgumentException("Query builder : invalid query type {$query->getType()}"); | ||
} | ||
|
||
$searchQueryParams = [ | ||
'value' => $query->getValue(), | ||
'boost' => $query->getBoost(), | ||
]; | ||
|
||
$searchQuery = ['span_term' => [$query->getField() => $searchQueryParams]]; | ||
|
||
if ($query->getName()) { | ||
$searchQuery['span_term']['_name'] = $query->getName(); | ||
} | ||
|
||
return $searchQuery; | ||
} | ||
} |
Oops, something went wrong.