Keeping track of which indexes exist on a table and how they are configured used to require manual inspection through the Structure Editor. With the new getIndexes() function, 4D developers can now introspect indexes directly from code, making it easy to verify configuration at runtime, build diagnostics tools, or validate deployments automatically.
4D adds a new function to introspect indexes directly from code:
var $indexes := ds.MyTable.getIndexes()
Calling getIndexes() on a table returns a collection describing every index defined on that table, whether it was created through the Structure Editor or via code with CREATE INDEX.
Index Entry Details
Each entry in the returned collection describes an index with the following attributes:
| Attribute | Type | Description |
|---|---|---|
type |
integer | Index algorithm type (relevant when “Automatic” is selected) |
automatic |
boolean | True if the “Automatic” index is selected |
name |
text | Index name, if available |
kind |
text | "keywords" or "regular" |
attributes |
collection | Fields covered by the index |
UUID |
text | Unique identifier of the index |
uniqueKey |
boolean | Whether the index enforces uniqueness |
This makes it possible to verify the status of a field’s index at runtime, which is particularly useful for diagnostics and automated deployment scripts.

var $indexes:=ds.Discuss.getIndexes()

The Benefits
Before getIndexes(), confirming that a critical index existed or that it was configured with the right algorithm meant opening the Structure Editor and checking manually. That doesn’t scale for automated workflows. With this function, you can:
- Validate deployments: check that all expected indexes are present right after a structure update or a database migration.
- Build diagnostic tools: surface index configuration in an admin panel or health-check endpoint.
- Audit uniqueness constraints: quickly find which fields are protected by a uniqueKey index.
- Identify index type: distinguish standard, keyword, and vector indexes (Cosine, Dot, Euclidean) by inspecting the type and kind attributes.
Conclusion
getIndexes() closes a gap in 4D’s index management API: developers no longer need to rely on the user interface to know what indexes exist on a table. Combined with CREATE INDEX, SET INDEX, and DELETE INDEX, it completes a fully programmatic workflow for managing indexes.
Comments are not currently available for this post.