apache/cassandra · error · IndexNotFound
Index {} not found
Error message
Index {} not found What it means
Shell.get_index_meta looks up a secondary index by name in KeyspaceMetadata.indexes. If the index name is absent, it raises IndexNotFound. Indexes are keyspace-scoped, so a valid index in another keyspace still fails here.
Source
Thrown at pylib/cqlshlib/cqlshmain.py:600
table_meta = TableMetadata(ks_meta, 'role_permissions')
table_meta.columns['role'] = ColumnMetadata(table_meta, 'role', cassandra.cqltypes.UTF8Type)
table_meta.columns['resource'] = ColumnMetadata(table_meta, 'resource', cassandra.cqltypes.UTF8Type)
table_meta.columns['permission'] = ColumnMetadata(table_meta, 'permission', cassandra.cqltypes.UTF8Type)
elif tablename == 'generated_values':
ks_meta = KeyspaceMetadata(ksname, True, None, None)
table_meta = TableMetadata(ks_meta, 'generated_values')
table_meta.columns['generated_password'] = ColumnMetadata(table_meta, 'generated_password', cassandra.cqltypes.UTF8Type)
table_meta.columns['generated_role_name'] = ColumnMetadata(table_meta, 'generated_role_name', cassandra.cqltypes.UTF8Type)
else:
raise ColumnFamilyNotFound("Column family {} not found".format(tablename))
def get_index_meta(self, ksname, idxname):
if ksname is None:
ksname = self.current_keyspace
ksmeta = self.get_keyspace_meta(ksname)
if idxname not in ksmeta.indexes:
raise IndexNotFound("Index {} not found".format(idxname))
return ksmeta.indexes[idxname]
def get_view_meta(self, ksname, viewname):
if ksname is None:
ksname = self.current_keyspace
ksmeta = self.get_keyspace_meta(ksname)
if viewname not in ksmeta.views:
raise MaterializedViewNotFound("Materialized view '{}' not found".format(viewname))
return ksmeta.views[viewname]
def get_object_meta(self, ks, name):
if name is None:
if ks and ks in self.conn.metadata.keyspaces:
return self.conn.metadata.keyspaces[ks]
elif self.current_keyspace is None:
raise ObjectNotFound("'{}' not found in keyspaces".format(ks))View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Run DESCRIBE KEYSPACE <ks> to see actual index names and correct the name.
- Include the keyspace explicitly and confirm the current keyspace is right.
- Refresh schema metadata / reconnect if the index was just created.
- Create the index with CREATE INDEX if it does not exist.
Example fix
// before
shell.get_index_meta('ks', 'users_by_email_idx') # IndexNotFound
// after
shell.get_index_meta('ks', 'users_email_idx') # exact index name from schema Defensive patterns
Strategy: validation
Validate before calling
ksmeta = shell.get_keyspace_meta(ksname)
if idxname not in ksmeta.indexes:
raise LookupError(f"Index {idxname} missing in {ksname}") Type guard
def index_exists(shell, ksname, idxname):
return idxname in shell.get_keyspace_meta(ksname).indexes Try / catch
try:
imeta = shell.get_index_meta(ksname, idxname)
except IndexNotFound:
imeta = None # use table metadata and scan its index definitions instead Prevention
- Use the exact index name, not the table name — check DESCRIBE KEYSPACE output.
- Keyspace-qualify index lookups.
- Refresh schema metadata after CREATE/DROP INDEX.
When it happens
Trigger: get_index_meta(ksname, idxname) with idxname not present in ksmeta.indexes — e.g. DESCRIBE of a dropped/typo'd index, or metadata fetched before a CREATE INDEX completed.
Common situations: Referring to an index by its backing table name instead of the actual index name; index dropped by another session; schema disagreement after CREATE INDEX; wrong keyspace in scope.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- User type {!r} not found
- Keyspace %r not found.
- Column family {} not found
- Materialized view '{}' not found
- '{}' not found in keyspace '{}'
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/b4cb216cc1a286e3.
Report an issue: GitHub.