44
55namespace CoreShop2VueStorefrontBundle \Bridge ;
66
7+ use CoreShop2VueStorefrontBundle \Bridge \SwappingIndexService ;
78use ONGR \ElasticsearchBundle \Mapping \Converter ;
89use ONGR \ElasticsearchBundle \Mapping \IndexSettings ;
910use ONGR \ElasticsearchBundle \Service \IndexService ;
@@ -77,7 +78,7 @@ public function __construct(ContainerInterface $container, Converter $converter,
7778 /**
7879 * @return array<array{persister: PersisterFactory, store: string, language: string, type: string}>
7980 */
80- public function create (?string $ site = null , ?string $ type = null , ?string $ language = null , ?string $ store = null ): array
81+ public function create (?string $ site = null , ?string $ type = null , ?string $ language = null , ?string $ store = null , ? string $ runTimestamp = null ): array
8182 {
8283 $ options = $ this ->resolver ->resolve (['site ' => $ site , 'type ' => $ type , 'language ' => $ language , 'store ' => $ store ]);
8384
@@ -115,16 +116,9 @@ public function create(?string $site = null, ?string $type = null, ?string $lang
115116 ];
116117
117118 $ indexName = $ this ->inject ($ this ->elasticsearchConfig ['index ' ], $ variables );
118- $ settings = new IndexSettings (
119- $ className ,
120- $ indexName ,
121- $ indexName ,
122- $ this ->elasticsearchConfig ['templates ' ][$ className ] ?? [],
123- $ this ->inject ($ this ->elasticsearchConfig ['hosts ' ], $ variables , true )
124- );
125119 $ indexSettings = new IndexSettings (
126120 $ className ,
127- $ indexName ,
121+ $ runTimestamp ? $ indexName . ' _ ' . $ runTimestamp : $ indexName ,
128122 $ indexName ,
129123 array_replace_recursive (
130124 $ indexSettings ->getIndexMetadata (),
@@ -139,6 +133,10 @@ public function create(?string $site = null, ?string $type = null, ?string $lang
139133 $ indexSettings
140134 );
141135
136+ if ($ runTimestamp ) {
137+ $ indexService = new SwappingIndexService ($ indexService , $ runTimestamp );
138+ }
139+
142140 $ persisters [] = [
143141 'persister ' => new EnginePersister ($ indexService , $ this ->documentMapperFactory , $ language , $ concreteStore ),
144142 'site ' => $ name ,
0 commit comments