-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from hkulekci/alias-with-filter-solution
filtered alias introduced for the write index to prevent duplicated d…
- Loading branch information
Showing
3 changed files
with
77 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Matchish\ScoutElasticSearch\ElasticSearch; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class FilteredAlias implements Alias | ||
{ | ||
/** | ||
* @var Alias | ||
*/ | ||
private Alias $origin; | ||
|
||
private Index $index; | ||
|
||
public function __construct(Alias $origin, Index $index) | ||
{ | ||
$this->origin = $origin; | ||
$this->index = $index; | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return $this->origin->name(); | ||
} | ||
|
||
public function config(): array | ||
{ | ||
return array_merge($this->origin->config(), [ | ||
'filter' => [ | ||
'bool' => [ | ||
'must_not' => [ | ||
[ | ||
'term' => [ | ||
'_index' => $this->index->name(), | ||
], | ||
], | ||
], | ||
], | ||
], | ||
]); | ||
} | ||
} |
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