2626use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Indexer \Error \MalformedBulkRequestError ;
2727use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Service \DimensionsService ;
2828use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Service \ErrorHandlingService ;
29+ use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Service \IndexNameService ;
2930use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Service \NodeTypeIndexingConfiguration ;
3031use Flowpack \ElasticSearch \Domain \Model \Document as ElasticSearchDocument ;
3132use Flowpack \ElasticSearch \Domain \Model \Index ;
@@ -169,7 +170,7 @@ public function getIndexName(): string
169170 {
170171 $ indexName = $ this ->searchClient ->getIndexName ();
171172 if ($ this ->indexNamePostfix !== '' ) {
172- $ indexName .= ' - ' . $ this ->indexNamePostfix ;
173+ $ indexName .= IndexNameService:: INDEX_PART_SEPARATOR . $ this ->indexNamePostfix ;
173174 }
174175
175176 return $ indexName ;
@@ -506,7 +507,7 @@ public function updateIndexAlias(): void
506507
507508 $ aliasActions = [];
508509 try {
509- $ indexNames = $ this ->indexDriver ->indexesByAlias ($ aliasName );
510+ $ indexNames = $ this ->indexDriver ->getIndexeNamesByAlias ($ aliasName );
510511 if ($ indexNames === []) {
511512 // if there is an actual index with the name we want to use as alias, remove it now
512513 $ this ->indexDriver ->deleteIndex ($ aliasName );
@@ -539,22 +540,18 @@ public function updateIndexAlias(): void
539540
540541 /**
541542 * Update the main alias to allow to query all indices at once
543+ * @throws Exception
542544 */
543545 public function updateMainAlias ()
544546 {
545547 $ aliasActions = [];
546548 $ aliasNamePrefix = $ this ->searchClient ->getIndexNamePrefix (); // The alias name is the unprefixed index name
547549
548- $ indexNames = $ this ->indexDriver ->indexesByPrefix ($ aliasNamePrefix );
549- $ indexNames = \array_values (\array_filter ($ indexNames , function ($ indexName ) {
550- $ suffix = '- ' . $ this ->indexNamePostfix ;
551- $ indexNameParts = \explode ('- ' , $ indexName );
552- return substr ($ indexName , 0 - strlen ($ suffix )) === $ suffix && count ($ indexNameParts ) === 3 ;
553- }));
550+ $ indexNames = IndexNameService::filterIndexNamesByPostfix ($ this ->indexDriver ->getIndexeNamesByPrefix ($ aliasNamePrefix ), $ this ->indexNamePostfix );
554551
555552 $ cleanupAlias = function ($ alias ) use (&$ aliasActions ) {
556553 try {
557- $ indexNames = $ this ->indexDriver ->indexesByAlias ($ alias );
554+ $ indexNames = $ this ->indexDriver ->getIndexeNamesByAlias ($ alias );
558555 if ($ indexNames === []) {
559556 // if there is an actual index with the name we want to use as alias, remove it now
560557 $ this ->indexDriver ->deleteIndex ($ alias );
@@ -577,7 +574,7 @@ public function updateMainAlias()
577574 };
578575
579576 $ postfix = function ($ alias ) {
580- return $ alias . ' - ' . $ this ->indexNamePostfix ;
577+ return $ alias . IndexNameService:: INDEX_PART_SEPARATOR . $ this ->indexNamePostfix ;
581578 };
582579
583580 if (\count ($ indexNames ) > 0 ) {
@@ -614,15 +611,15 @@ public function removeOldIndices(): array
614611 {
615612 $ aliasName = $ this ->searchClient ->getIndexName (); // The alias name is the unprefixed index name
616613
617- $ currentlyLiveIndices = $ this ->indexDriver ->indexesByAlias ($ aliasName );
614+ $ currentlyLiveIndices = $ this ->indexDriver ->getIndexeNamesByAlias ($ aliasName );
618615
619616 $ indexStatus = $ this ->systemDriver ->status ();
620617 $ allIndices = array_keys ($ indexStatus ['indices ' ]);
621618
622619 $ indicesToBeRemoved = [];
623620
624621 foreach ($ allIndices as $ indexName ) {
625- if (strpos ($ indexName , $ aliasName . ' - ' ) !== 0 ) {
622+ if (strpos ($ indexName , $ aliasName . IndexNameService:: INDEX_PART_SEPARATOR ) !== 0 ) {
626623 // filter out all indices not starting with the alias-name, as they are unrelated to our application
627624 continue ;
628625 }
0 commit comments