@@ -193,6 +193,9 @@ public function addDocs(array $documents, $storeId, $mappedIndexerId)
193
193
*/
194
194
public function cleanIndex ($ storeId , $ mappedIndexerId )
195
195
{
196
+ // needed to fix bug with double indices in alias because of second reindex in same process
197
+ unset($ this ->preparedIndex [$ storeId ]);
198
+
196
199
$ this ->checkIndex ($ storeId , $ mappedIndexerId , true );
197
200
$ indexName = $ this ->indexNameResolver ->getIndexName ($ storeId , $ mappedIndexerId , $ this ->preparedIndex );
198
201
if ($ this ->client ->isEmptyIndex ($ indexName )) {
@@ -203,7 +206,7 @@ public function cleanIndex($storeId, $mappedIndexerId)
203
206
// prepare new index name and increase version
204
207
$ indexPattern = $ this ->indexNameResolver ->getIndexPattern ($ storeId , $ mappedIndexerId );
205
208
$ version = (int )(str_replace ($ indexPattern , '' , $ indexName ));
206
- $ newIndexName = $ indexPattern . ++$ version ;
209
+ $ newIndexName = $ indexPattern . ( ++$ version) ;
207
210
208
211
// remove index if already exists
209
212
if ($ this ->client ->indexExists ($ newIndexName )) {
@@ -354,12 +357,14 @@ protected function prepareIndex($storeId, $indexName, $mappedIndexerId)
354
357
{
355
358
$ this ->indexBuilder ->setStoreId ($ storeId );
356
359
$ settings = $ this ->indexBuilder ->build ();
357
- $ allAttributeTypes = $ this ->fieldMapper ->getAllAttributesTypes ([
358
- 'entityType ' => $ mappedIndexerId ,
359
- // Use store id instead of website id from context for save existing fields mapping.
360
- // In future websiteId will be eliminated due to index stored per store
361
- 'websiteId ' => $ storeId
362
- ]);
360
+ $ allAttributeTypes = $ this ->fieldMapper ->getAllAttributesTypes (
361
+ [
362
+ 'entityType ' => $ mappedIndexerId ,
363
+ // Use store id instead of website id from context for save existing fields mapping.
364
+ // In future websiteId will be eliminated due to index stored per store
365
+ 'websiteId ' => $ storeId
366
+ ]
367
+ );
363
368
$ settings ['index ' ]['mapping ' ]['total_fields ' ]['limit ' ] = $ this ->getMappingTotalFieldsLimit ($ allAttributeTypes );
364
369
$ this ->client ->createIndex ($ indexName , ['settings ' => $ settings ]);
365
370
$ this ->client ->addFieldsMapping (
0 commit comments