Skip to content

Commit 86a57d7

Browse files
authored
Merge pull request #3468 from rbayet/feat-customize-time-before-index-is-ghost
[Core] Setting to customize time before an index becomes ghost
2 parents bb8645f + 15292a3 commit 86a57d7

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

src/module-elasticsuite-core/Helper/IndexSettings.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,16 @@ public function getNumberOfReplicasPerIndex(string $indexIdentifier): int
300300
return (int) $this->getIndicesSettingsConfigParam('number_of_replicas');
301301
}
302302

303+
/**
304+
* Returns the time elapsed (in seconds) since its creation after which a non-live index is to be considered ghost.
305+
*
306+
* @return int
307+
*/
308+
public function getTimeBeforeGhost(): int
309+
{
310+
return (int) $this->getIndicesSettingsConfigParam('ghost_timeout');
311+
}
312+
303313
/**
304314
* Get number the batch indexing size from the configuration.
305315
*

src/module-elasticsuite-core/etc/adminhtml/system.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,30 @@
9090

9191
<group id="indices_settings" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
9292
<label>Indices Settings</label>
93-
<field id="alias" translate="label" type="text" sortOrder="57" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
93+
<field id="alias" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
9494
<label>Indices Alias Name</label>
9595
</field>
96-
<field id="indices_pattern" translate="label" type="text" sortOrder="58" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
96+
<field id="indices_pattern" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
9797
<label>Indices Name Pattern</label>
9898
</field>
99-
<field id="number_of_shards" translate="label" type="text" sortOrder="59" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
99+
<field id="number_of_shards" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
100100
<label>Default Number of Shards per Index</label>
101101
<frontend_class>validate-number</frontend_class>
102102
</field>
103-
<field id="number_of_replicas" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
103+
<field id="number_of_replicas" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
104104
<label>Default Number of Replicas per Index</label>
105105
<frontend_class>validate-number</frontend_class>
106106
</field>
107-
<field id="custom_number_of_shards_and_replicas_per_index" translate="label" sortOrder="61" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
107+
<field id="custom_number_of_shards_and_replicas_per_index" translate="label" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
108108
<label>Custom settings per Index</label>
109109
<frontend_model>Smile\ElasticsuiteCore\Block\Adminhtml\Form\Field\IndicesSettings\DynamicField</frontend_model>
110110
<backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
111111
</field>
112+
<field id="ghost_timeout" translate="label comment" type="text" sortOrder="60" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
113+
<label>Time for an index to be considered Ghost (in seconds)</label>
114+
<comment><![CDATA[Elasticsuite derelict indices resulting from a failed full reindex are considered ghost after this amount of time (in seconds) has elapsed since their creation. You can reduce this amount of time to speed up ghost indices cleanup, but take care to add a safety on top of the maximum reindexing duration of the more complex index of your platform (usually a catalog_product/product search index). Defaults to 172,800 seconds (2 days), minimum value: 3600 (1 hour).]]></comment>
115+
<validate>integer validate-greater-than-zero validate-number-range number-range-3600-172800</validate>
116+
</field>
112117
</group>
113118

114119
</section>

src/module-elasticsuite-core/etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<number_of_shards>1</number_of_shards>
3535
<number_of_replicas>0</number_of_replicas>
3636
<batch_indexing_size>1000</batch_indexing_size>
37+
<ghost_timeout>172800</ghost_timeout>
3738
</indices_settings>
3839
</smile_elasticsuite_core_base_settings>
3940

src/module-elasticsuite-core/i18n/en_US.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,5 @@ Autocomplete,Autocomplete
128128
"Custom stemmer","Custom stemmer"
129129
"In the list ""[default]"" indicates the stemmer used by Elasticsuite by default for the language, while ""[recommended]"" indicates the stemmer is the one or one of those recommended for that language by Elasticsearch in its <a href='https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-stemmer-tokenfilter.html#analysis-stemmer-tokenfilter-configure-parms' target='_blank'>online documentation</a>. Those can differ, hence this configuration parameter.","In the list ""[default]"" indicates the stemmer used by Elasticsuite by default for the language, while ""[recommended]"" indicates the stemmer is the one or one of those recommended for that language by Elasticsearch in its <a href='https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-stemmer-tokenfilter.html#analysis-stemmer-tokenfilter-configure-parms' target='_blank'>online documentation</a>. Those can differ, hence this configuration parameter."
130130
"Please select a stemmer for the store","Please select a stemmer for the store"
131+
"Time for an index to be considered Ghost (in seconds)","Time for an index to be considered Ghost (in seconds)"
132+
"Elasticsuite derelict indices resulting from a failed full reindex are considered ghost after this amount of time (in seconds) has elapsed since their creation. You can reduce this amount of time to speed up ghost indices cleanup, but take care to add a safety on top of the maximum reindexing duration of the more complex index of your platform (usually a catalog_product/product search index). Defaults to 172,800 seconds (2 days), minimum value: 3600 (1 hour).","Elasticsuite derelict indices resulting from a failed full reindex are considered ghost after this amount of time (in seconds) has elapsed since their creation. You can reduce this amount of time to speed up ghost indices cleanup, but take care to add a safety on top of the maximum reindexing duration of the more complex index of your platform (usually a catalog_product/product search index). Defaults to 172,800 seconds (2 days), minimum value: 3600 (1 hour)."

src/module-elasticsuite-core/i18n/fr_FR.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,5 @@ General,Général
128128
"Custom stemmer","Stemmer spécifique"
129129
"In the list ""[default]"" indicates the stemmer used by Elasticsuite by default for the language, while ""[recommended]"" indicates the stemmer is the one or one of those recommended for that language by Elasticsearch in its <a href='https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-stemmer-tokenfilter.html#analysis-stemmer-tokenfilter-configure-parms' target='_blank'>online documentation</a>. Those can differ, hence this configuration parameter.","Dans la liste, ""[default]"" indique le stemmer utilisé par défaut par Elasticsuite pour la langue, tandis que ""[recommended]"" indique que le stemmer est celui ou l'un de deux recommendés pour cette langue par Elasticsearch dans sa <a href='https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-stemmer-tokenfilter.html#analysis-stemmer-tokenfilter-configure-parms' target='_blank'>documentation en ligne</a>. Ceux-ci peuvent différer, d'où l'existence de ce paramètre de configuration."
130130
"Please select a stemmer for the store","Veuillez sélectionner un stemmer pour le magasin"
131+
"Time for an index to be considered Ghost (in seconds)","Temps avant qu'un index soit considéré Fantôme (en secondes)"
132+
"Elasticsuite derelict indices resulting from a failed full reindex are considered ghost after this amount of time (in seconds) has elapsed since their creation. You can reduce this amount of time to speed up ghost indices cleanup, but take care to add a safety on top of the maximum reindexing duration of the more complex index of your platform (usually a catalog_product/product search index). Defaults to 172,800 seconds (2 days), minimum value: 3600 (1 hour).","Les index Elasticsuite résultant de l'échec d'une ré-indexation complète sont considérés comme fantômes après que cette période de temps (en secondes) s'est écoulée depuis leur création. Vous pouvez réduire cette période de temps pour accélérer la suppression des index fantômes, mais prenez soin d'ajouter une période de sécurité au temps de réindexation maximum de l'index le plus complexe de votre plateforme (généralement un index catalog_product/de recherche produits). Valeur par défaut: 172 800 secondes (2 jours), valeur minimum: 3600 (1 heure)."

src/module-elasticsuite-indices/Model/IndexStatusProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ private function isExternal(string $indexName): bool
160160
private function isGhost($indexDate): bool
161161
{
162162
try {
163-
return (new Zend_Date())->sub($indexDate)->getTimestamp() / self::SECONDS_IN_DAY >= self::NUMBER_DAYS_AFTER_INDEX_IS_GHOST;
163+
return (new Zend_Date())->sub($indexDate)->getTimestamp() >= $this->indexSettingsHelper->getTimeBeforeGhost();
164164
} catch (Zend_Date_Exception $e) {
165165
return false;
166166
}

0 commit comments

Comments
 (0)