apache/cassandra · error · InvalidRequestException

Table doesn't have an index named

Error message

Table %s doesn't have an index named %s

What it means

Thrown as an InvalidRequestException when the index registry has no index registered under the given name for the queried table. Cassandra looks up the index by name in the table's IndexRegistry; if it is absent the hint cannot be resolved. Message reads 'Table %s doesn't have an index named %s'.

Solutions

  1. Verify the index exists with DESCRIBE TABLE or querying system_schema.indexes and correct the name in the query
  2. Create the missing index with CREATE INDEX if it should exist
  3. Remove the USING INDEX clause so the query no longer depends on a specific index

Example fix

// before
SELECT * FROM users USING INDEX usr_email_idx;
// after
SELECT * FROM users USING INDEX users_email_idx;
Defensive patterns

Strategy: validation

Validate before calling

boolean exists = systemSchemaIndexes.stream().anyMatch(i -> i.keyspace.equals(table.keyspace) && i.name.equals(indexName) && i.table.equals(table.name));
if (!exists) throw new InvalidRequestException("Table " + table.name + " doesn't have an index named " + indexName);

Try / catch

try { session.execute(query); }
catch (InvalidRequestException e) {
    if (e.getMessage().contains("doesn't have an index named")) { /* recreate index or drop hint */ }
    else throw e;
}

Prevention

When it happens

Trigger: SELECT ... USING INDEX idx_name FROM tbl where idx_name is not a defined index on tbl (typo, index dropped, or index on another table).

Common situations: Index was DROPped or renamed but old queries still reference it; schema drift between application code and database; referencing an index that exists on a different table; case-sensitivity mistakes with quoted vs unquoted identifiers.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/130c77b906e3ad58. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/db/filter/IndexHints.java:441

        {
            IndexMetadata index = fetchIndex(indexName, table, indexRegistry);
            indexes.add(index);
        }

        return indexes;
    }

    private static IndexMetadata fetchIndex(QualifiedName indexName, TableMetadata table, IndexRegistry indexRegistry)
    {
        String name = indexName.getName();
        String keyspace = indexName.getKeyspace();

        if (keyspace != null && !table.keyspace.equals(keyspace))
            throw new InvalidRequestException(format(WRONG_KEYSPACE_ERROR, indexName));

        Index index = indexRegistry.getIndexByName(name);
        if (index == null)
            throw new InvalidRequestException(format(MISSING_INDEX_ERROR, table.name, name));

        return index.getIndexMetadata();
    }

    /**
     * Returns a comparator of index query plans based on which one has the most included indexes, so it can be used to
     * select the plans that satisfy the index hints first, and the plans that are closest to satisfy them later.
     *
     * @return a comparator of index query plans based on which one has the most included indexes
     */
    public Comparator<Index.QueryPlan> comparator()
    {
        return Comparator.comparing(plan -> Sets.intersection(included, metadata(plan.getIndexes())).size());
    }

    @Override
    public String toString()
    {

View on GitHub (pinned to 88fd0f6a0e)