diff --git a/elasticsearch_connector_autocomp.module b/elasticsearch_connector_autocomp.module
index 77bc698..99d8cc1 100644
--- a/elasticsearch_connector_autocomp.module
+++ b/elasticsearch_connector_autocomp.module
@@ -183,6 +183,12 @@ function elasticsearch_connector_autocomp_form_search_api_index_form_submit(arra
  * Implements hook_form_FORM_ID_alter().
  */
 function elasticsearch_connector_autocomp_form_search_api_index_fields_alter(&$form, FormStateInterface $form_state, $form_id) {
+
+  // Fallback if fields are not added yet.
+  if (empty($form['entity:node']['fields'])) {
+    return;
+  }
+
   /** @var \Drupal\search_api\IndexInterface $index_entity */
   $index_entity = $form_state->getFormObject()->getEntity();
   $ngram_index_analyzer_enabled = $index_entity->getThirdPartySetting('elasticsearch_connector', 'ngram_filter_enabled', FALSE);
