-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This add supports for `InCondition` with the already support for `OrCondition` and `EqualConditon` it should be possible to implement a `InCondition` in all adapters as `IN` is just a shortcut for `EqualCondition` on the same field `Or` connected. So instead of writing: ```php new Condition\OrCondition( new Condition\EqualCondition('tags', 'UI'), new Condition\EqualCondition('tags', 'UX'), new Condition\EqualCondition('tags', 'Frontend'), ); ``` It should now be possible to write: ```php new Condition\InCondition('tags', ['UI','UX','Frontend']) ``` fix #444 ### Todo - [x] Core: Add InCondition - [x] Memory - [x] Elasticsearch - [x] Opensearch - [x] Meilisearch - [x] Algolia - [x] Loupe - [x] Redisearch - [x] Solr - [x] Typesense Co-authored-by: ToshY <[email protected]>
- Loading branch information
1 parent
663bc73
commit c23e9f4
Showing
11 changed files
with
121 additions
and
0 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
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Schranz Search package. | ||
* | ||
* (c) Alexander Schranz <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Schranz\Search\SEAL\Search\Condition; | ||
|
||
class InCondition | ||
{ | ||
/** | ||
* @param list<string|int|float|bool> $values | ||
*/ | ||
public function __construct( | ||
public readonly string $field, | ||
public readonly array $values, | ||
) { | ||
} | ||
|
||
/** | ||
* @internal This method is for internal use and should not be called from outside. | ||
* | ||
* Some search engines do not support the `IN` operator, so we need to convert it to an `OR` condition. | ||
*/ | ||
public function createOrCondition(): OrCondition | ||
{ | ||
/** @var array<EqualCondition|GreaterThanCondition|GreaterThanEqualCondition|IdentifierCondition|LessThanCondition|LessThanEqualCondition|NotEqualCondition|AndCondition|OrCondition> $conditions */ | ||
$conditions = []; | ||
foreach ($this->values as $value) { | ||
$conditions[] = new EqualCondition($this->field, $value); | ||
} | ||
|
||
return new OrCondition(...$conditions); | ||
} | ||
} |
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