diff --git a/includes/classes/ElasticsearchErrorInterpreter.php b/includes/classes/ElasticsearchErrorInterpreter.php
index 147df4adc8..cf39e2060d 100644
--- a/includes/classes/ElasticsearchErrorInterpreter.php
+++ b/includes/classes/ElasticsearchErrorInterpreter.php
@@ -105,6 +105,16 @@ public function maybe_suggest_solution_for_es( $error ) {
}
if ( Utils\is_epio() ) {
+ if ( preg_match( '/you have reached the limit of indices your plan supports/', $error, $matches ) ) {
+ return [
+ 'error' => $error,
+ 'solution' => sprintf(
+ /* translators: ElasticPress.io Article URL */
+ __( 'Please refer to this article outlining how to address this issue.', 'elasticpress' ),
+ 'https://elasticpress.zendesk.com/hc/en-us/articles/26165267320461'
+ ),
+ ];
+ }
return [
'error' => $error,
'solution' => sprintf(
diff --git a/includes/classes/IndexHelper.php b/includes/classes/IndexHelper.php
index 21a90f8188..a5d6516d20 100644
--- a/includes/classes/IndexHelper.php
+++ b/includes/classes/IndexHelper.php
@@ -1412,8 +1412,10 @@ protected function on_error_update_and_clean( $error, $context = 'sync' ) {
esc_html__( 'Mapping failed: %s', 'elasticpress' ),
Utils\get_elasticsearch_error_reason( $error['message'] )
);
- $message .= "\n";
- $message .= esc_html__( 'Mapping has failed, which will cause ElasticPress search results to be incorrect. Please click `Delete all Data and Start a Fresh Sync` to retry mapping.', 'elasticpress' );
+ if ( $this->should_suggest_retry( $message ) ) {
+ $message .= "\n";
+ $message .= esc_html__( 'Mapping has failed, which will cause ElasticPress search results to be incorrect. Please click `Delete all Data and Start a Fresh Sync` to retry mapping.', 'elasticpress' );
+ }
break;
default:
/* translators: Error message */
@@ -1523,6 +1525,16 @@ protected function maybe_apply_feature_settings() {
Features::factory()->apply_draft_feature_settings();
}
+ /**
+ * Whether to suggest retrying the sync or not.
+ *
+ * @param string $message The message returned by the hosting server
+ * @return boolean
+ */
+ protected function should_suggest_retry( $message ) {
+ return ! preg_match( '/you have reached the limit of indices your plan supports/', $message );
+ }
+
/**
* Return singleton instance of class.
*
diff --git a/tests/php/TestElasticsearchErrorInterpreter.php b/tests/php/TestElasticsearchErrorInterpreter.php
index 12a6271027..1072460feb 100644
--- a/tests/php/TestElasticsearchErrorInterpreter.php
+++ b/tests/php/TestElasticsearchErrorInterpreter.php
@@ -132,4 +132,23 @@ public function test_maybe_suggest_solution_for_es_limit_fields() {
$this->assertSame( 'Limit of total fields [???] in index [???] has been exceeded', $suggested['error'] );
$this->assertSame( $solution, $suggested['solution'] );
}
+
+ /**
+ * Test the `maybe_suggest_solution_for_es` method when the indices limit was reached on EP.io
+ *
+ * @since 5.1.0
+ * @group elasticsearch-error-interpreter
+ */
+ public function test_maybe_suggest_solution_for_es_limit_of_indices() {
+ $this->force_epio();
+
+ $error_interpreter = new ElasticsearchErrorInterpreter();
+
+ $error = 'It seems you have reached the limit of indices your plan supports and we were not able to create a new index. Currently, you can have up to 3 indices.';
+ $solution = 'Please refer to this article outlining how to address this issue.';
+ $suggested = $error_interpreter->maybe_suggest_solution_for_es( $error );
+
+ $this->assertSame( $error, $suggested['error'] );
+ $this->assertSame( $solution, $suggested['solution'] );
+ }
}
diff --git a/tests/php/includes/classes/BaseTestCase.php b/tests/php/includes/classes/BaseTestCase.php
index da87c4ed66..44f5c5a468 100644
--- a/tests/php/includes/classes/BaseTestCase.php
+++ b/tests/php/includes/classes/BaseTestCase.php
@@ -218,4 +218,13 @@ public function assertDecayDisabled( $query ) {
)
);
}
+
+ /**
+ * Forces tests to use EP.io
+ *
+ * @since 5.1.0
+ */
+ protected function force_epio() {
+ update_site_option( 'ep_host', 'https://prefix.elasticpress.io/' );
+ }
}