How to fix IndexNotFoundException: no such index [index_name] in Elasticsearch

ElasticsearchINTERMEDIATEMEDIUMUpdated Dec 22, 2025· 187 views

This error occurs when Elasticsearch cannot find the specified index during a search, index, or other operation. The index may have been deleted, never created, or you might be using the wrong index name. This is a common error when applications reference indices that don't exist or have been renamed.

Quick fix

Fixes IndexNotFoundException: no such index [index_name]

# Check if a specific index exists
curl -X GET "localhost:9200/my-index" -u "username:password"

# Check multiple indices
curl -X GET "localhost:9200/index1,index2,index3" -u "username:password"

# Use HEAD request for simple existence check (returns 200 if exists, 404 if not)
curl -X HEAD "localhost:9200/my-index" -u "username:password"

# List all indices in the cluster
curl -X GET "localhost:9200/_cat/indices?v" -u "username:password"

# List indices with specific pattern
curl -X GET "localhost:9200/_cat/indices/my-*?v" -u "username:password"
  1. Check if the index exists using the indices API
  2. Create the missing index with proper settings
  3. Enable auto-create for development environments
  4. Use index aliases for flexible index management
elasticsearch — error
# Check if a specific index exists
curl -X GET "localhost:9200/my-index" -u "username:password"
# Check multiple indices
curl -X GET "localhost:9200/index1,index2,index3" -u "username:password"
# Use HEAD request for simple existence check (returns 200 if exists, 404 if not)
curl -X HEAD "localhost:9200/my-index" -u "username:password"
# List all indices in the cluster
curl -X GET "localhost:9200/_cat/indices?v" -u "username:password"
# List indices with specific pattern
curl -X GET "localhost:9200/_cat/indices/my-*?v" -u "username:password"
IndexNotFoundException: no such index [index_name]

What this error means

The "IndexNotFoundException: no such index [index_name]" error indicates that Elasticsearch cannot locate an index with the specified name. An index in Elasticsearch is similar to a database table in traditional SQL databases - it's where documents are stored and indexed for search. This error typically occurs when: 1. You're trying to query, index, or update documents in an index that doesn't exist 2. The index name is misspelled or uses incorrect casing 3. The index was deleted or hasn't been created yet 4. You're using an alias that doesn't point to any existing index 5. The index exists in a different cluster or node Elasticsearch requires indices to exist before you can perform operations on them (unless auto-create is enabled). When this error appears, it means the operation cannot proceed because the target storage location doesn't exist in the cluster.

Typical symptoms

  • Search queries return "IndexNotFoundException" with the missing index name
  • Indexing operations fail with "no such index" errors
  • Bulk API requests show individual failures for operations targeting non-existent indices
  • Application logs show repeated failures when trying to access specific indices
  • Dashboard or monitoring tools show missing indices in cluster health reports

Common causes

  1. The index was never created before attempting to use it
  2. The index was deleted (manually or via lifecycle policy)
  3. Typographical errors in the index name (case sensitivity matters)
  4. Using index aliases that don't point to any existing index
  5. Application configuration points to wrong index names
  6. Cluster restart or node failure caused index metadata loss
  7. Index creation failed silently due to permission issues
  8. Using time-based index patterns that haven't rolled over yet

How to fix "IndexNotFoundException: no such index [index_name]"

1Check if the index exists using the indices API

First, verify whether the index actually exists in your Elasticsearch cluster:

bash
# Check if a specific index exists
curl -X GET "localhost:9200/my-index" -u "username:password"

# Check multiple indices
curl -X GET "localhost:9200/index1,index2,index3" -u "username:password"

# Use HEAD request for simple existence check (returns 200 if exists, 404 if not)
curl -X HEAD "localhost:9200/my-index" -u "username:password"

# List all indices in the cluster
curl -X GET "localhost:9200/_cat/indices?v" -u "username:password"

# List indices with specific pattern
curl -X GET "localhost:9200/_cat/indices/my-*?v" -u "username:password"

If the index doesn't exist, you'll need to create it. If it does exist, check for typos or case differences in your index name.

2Create the missing index with proper settings

If the index doesn't exist, create it with appropriate settings and mappings:

bash
# Basic index creation
curl -X PUT "localhost:9200/my-index" -u "username:password" -H 'Content-Type: application/json' -d'
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1,
    "index": {
      "refresh_interval": "1s"
    }
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "timestamp": {
        "type": "date"
      }
    }
  }
}
'

# For time-series data, consider using data streams
curl -X PUT "localhost:9200/_index_template/my-template" -u "username:password" -H 'Content-Type: application/json' -d'
{
  "index_patterns": ["logs-*"],
  "data_stream": {},
  "priority": 200,
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 1
    }
  }
}
'

# Then create the data stream
curl -X PUT "localhost:9200/_data_stream/logs-app" -u "username:password"

Choose appropriate shard counts based on your data volume and performance requirements.

3Enable auto-create for development environments

For development or testing environments, you can enable automatic index creation:

bash
# Check current auto-create setting
curl -X GET "localhost:9200/_cluster/settings?include_defaults=true&filter_path=**.action.auto_create_index" -u "username:password"

# Enable auto-create for specific index patterns
curl -X PUT "localhost:9200/_cluster/settings" -u "username:password" -H 'Content-Type: application/json' -d'
{
  "persistent": {
    "action.auto_create_index": "my-index-*,logs-*,-.*,+*"
  }
}
'

# Enable auto-create for all indices (not recommended for production)
curl -X PUT "localhost:9200/_cluster/settings" -u "username:password" -H 'Content-Type: application/json' -d'
{
  "persistent": {
    "action.auto_create_index": "true"
  }
}
'

# Disable auto-create (default in production)
curl -X PUT "localhost:9200/_cluster/settings" -u "username:password" -H 'Content-Type: application/json' -d'
{
  "persistent": {
    "action.auto_create_index": "false"
  }
}

Warning: Auto-create can be a security risk in production as it allows any user to create indices. Use index templates to control auto-created index settings.

4Use index aliases for flexible index management

Implement index aliases to avoid hardcoded index names in your application:

bash
# Create an alias pointing to your index
curl -X POST "localhost:9200/_aliases" -u "username:password" -H 'Content-Type: application/json' -d'
{
  "actions": [
    {
      "add": {
        "index": "my-index-2024.01.01",
        "alias": "current-index"
      }
    }
  ]
}
'

# Query using the alias
curl -X GET "localhost:9200/current-index/_search" -u "username:password" -H 'Content-Type: application/json' -d'
{
  "query": {
    "match_all": {}
  }
}
'

# Switch alias to new index (zero downtime)
curl -X POST "localhost:9200/_aliases" -u "username:password" -H 'Content-Type: application/json' -d'
{
  "actions": [
    {
      "remove": {
        "index": "my-index-2024.01.01",
        "alias": "current-index"
      }
    },
    {
      "add": {
        "index": "my-index-2024.01.02",
        "alias": "current-index"
      }
    }
  ]
}
'

# Check which indices an alias points to
curl -X GET "localhost:9200/_alias/current-index" -u "username:password"

Aliases allow you to change the underlying index without updating application code.

5Implement index existence checks in application code

Add defensive checks in your application to handle missing indices gracefully:

javascript
// Example: Check index existence before operations
const { Client } = require('@elastic/elasticsearch');
const client = new Client({ node: 'http://localhost:9200' });

async function safeIndexOperation(indexName, document) {
  try {
    // Check if index exists
    const exists = await client.indices.exists({ index: indexName });

    if (!exists) {
      console.log('Index ' + indexName + ' doesn\'t exist. Creating...');

      // Create index with default settings
      await client.indices.create({
        index: indexName,
        body: {
          settings: {
            number_of_shards: 1,
            number_of_replicas: 1
          }
        }
      });

      console.log('Index ' + indexName + ' created successfully.');
    }

    // Now perform the operation
    const response = await client.index({
      index: indexName,
      body: document
    });

    return response;
  } catch (error) {
    if (error.meta?.body?.error?.type === 'index_not_found_exception') {
      console.error('Index ' + indexName + ' not found. Please create it first.');
      // Implement retry logic or fallback
    }
    throw error;
  }
}

// Example: Bulk operations with error handling
async function safeBulkOperation(operations) {
  const response = await client.bulk({
    body: operations,
    refresh: true
  });

  if (response.errors) {
    const failedIndices = new Set();

    // Check for index not found errors
    response.items.forEach(item => {
      if (item.index?.error?.type === 'index_not_found_exception') {
        const indexName = item.index.error.index;
        failedIndices.add(indexName);
      }
    });

    // Handle missing indices
    for (const indexName of failedIndices) {
      console.log('Creating missing index: ' + indexName);
      await client.indices.create({ index: indexName });
    }

    // Retry failed operations
    if (failedIndices.size > 0) {
      return await client.bulk({
        body: operations,
        refresh: true
      });
    }
  }

  return response;
}

Advanced notes

## Advanced Index Management

### Index Lifecycle Management (ILM)
Use ILM policies to automate index lifecycle and prevent accidental deletions:

bash
# Create ILM policy
curl -X PUT "localhost:9200/_ilm/policy/my-policy" -u "username:password" -H 'Content-Type: application/json' -d'
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_size": "50gb",
            "max_age": "30d"
          }
        }
      },
      "delete": {
        "min_age": "90d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}
'

# Apply policy to index template
curl -X PUT "localhost:9200/_index_template/my-template" -u "username:password" -H 'Content-Type: application/json' -d'
{
  "index_patterns": ["logs-*"],
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 1,
      "index.lifecycle.name": "my-policy",
      "index.lifecycle.rollover_alias": "logs"
    }
  }
}

### Cross-Cluster Search
If using multiple clusters, configure cross-cluster search:

bash
# Add remote cluster
curl -X PUT "localhost:9200/_cluster/settings" -u "username:password" -H 'Content-Type: application/json' -d'
{
  "persistent": {
    "cluster.remote.cluster2.seeds": ["other-cluster:9300"]
  }
}
'

# Search across clusters
curl -X GET "localhost:9200/cluster2:my-remote-index/_search" -u "username:password"

### Index Recovery
If indices disappeared due to node failures:

1. Check cluster state: GET /_cluster/state
2. Look for unassigned shards: GET /_cat/shards?v&h=index,shard,prirep,state,unassigned.reason
3. Check disk space on data nodes
4. Review Elasticsearch logs for corruption errors

### Security Considerations
- Use index-level security to control access
- Implement audit logging to track index deletions
- Regular backups using snapshot/restore API
- Monitor index count and size anomalies

Frequently asked questions

What does "IndexNotFoundException: no such index [index_name]" mean?
The "IndexNotFoundException: no such index [index_name]" error indicates that Elasticsearch cannot locate an index with the specified name. An index in Elasticsearch is similar to a database table in traditional SQL databases - it's where documents are stored and indexed for search. This error typically occurs when: 1.
How do I fix "IndexNotFoundException: no such index [index_name]"?
This error occurs when Elasticsearch cannot find the specified index during a search, index, or other operation. The index may have been deleted, never created, or you might be using the wrong index name. This is a common error when applications reference indices that don't exist or have been renamed.
What causes "IndexNotFoundException: no such index [index_name]"?
The index was never created before attempting to use it The index was deleted (manually or via lifecycle policy) Typographical errors in the index name (case sensitivity matters)
Is the "IndexNotFoundException: no such index [index_name]" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading