cayleygraph/cayley · error
no indexes defined
Error message
no indexes defined
What it means
bestUnique computes an index combination for existence checks by intersecting available indexes. If qs.indexes.all is empty — no indexes are registered on the store — it returns "no indexes defined" instead of an intersection plan. This indicates the store was opened without index metadata being initialized.
Source
Thrown at graph/kv/indexing.go:826
}
qs.indexes.Lock()
defer qs.indexes.Unlock()
if len(qs.indexes.exists) != 0 {
return qs.indexes.exists, nil
}
for _, in := range qs.indexes.all {
if in.Unique {
if clog.V(2) {
clog.Infof("using unique index: %v", in.Dirs)
}
qs.indexes.exists = []QuadIndex{in}
return qs.indexes.exists, nil
}
}
// TODO: find best combination of indexes
inds := qs.indexes.all
if len(inds) == 0 {
return nil, fmt.Errorf("no indexes defined")
}
if clog.V(2) {
clog.Infof("using index intersection: %v", inds)
}
qs.indexes.exists = inds
return qs.indexes.exists, nil
}
func hasDir(dirs []quad.Direction, d quad.Direction) bool {
for _, d2 := range dirs {
if d == d2 {
return true
}
}
return false
}
func (qs *QuadStore) bestIndexes(dirs []quad.Direction) []QuadIndex {View on GitHub (pinned to 81dcd7d73e)
Solutions
- Re-initialize/reindex the store so index metadata is created before running queries.
- Check startup logs for earlier indexing errors (e.g. 'cannot decode indexes') that left the index set empty, and fix the root cause.
- Verify the database directory belongs to the same Cayley version/format; migrate via export/import if not.
- If the directory is disposable, recreate it with cayley init and reload data.
Example fix
// before: querying a never-indexed directory cayley query 'g.V().Has(...)' // no indexes defined // after cayley init --store /path/db && cayley load --store /path/db --files data.nq cayley query 'g.V().Has(...)'
Defensive patterns
Strategy: validation
Validate before calling
if len(qs.indexes.all) == 0 {
return fmt.Errorf("store has no indexes; run indexing before queries")
} Try / catch
res, err := qs.hasPrimitive(...)
if err != nil && err.Error() == "no indexes defined" {
return fmt.Errorf("re-initialize store: cayley init + reindex required")
} Prevention
- Always initialize stores with cayley init before loading/querying.
- Watch startup logs for index initialization failures and abort startup if indexes are empty.
- Keep data directories version-consistent; migrate via export/import instead of opening in-place across formats.
When it happens
Trigger: hasPrimitive-driven lookups on a kv QuadStore whose indexes.all slice is empty because index metadata was never written or was loaded as empty/corrupt at open time.
Common situations: Querying a store that failed index initialization at startup; custom/legacy database directory without index metadata; a bug or interrupted initialization that left the store with zero indexes.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- ErrNoBucket
- trying to add to map bucket with invalid key: %v
- trying to add to map bucket %s with key 0
- couldn't write version: %v
- HTTP Request needed
AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06).
Data as JSON: /api/errors/3f32d3ecc89a9d65.
Report an issue: GitHub.