INDEX_MULTI
All functions > ARRAY_OF_ROWS > INDEX_MULTI
Returns an index multi computed from the given array and key.
Syntax
INDEX_MULTI(base: ARRAY<ROW<T>>, key: FIELD) → INDEX
sql
Type Parameters:
T
: Any row type with named fields
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
base | ARRAY<ROW<T>> | Yes | Array of rows to index |
key | FIELD | Yes | Field name to use as lookup key |
Returns
INDEX - Map from key values to arrays of positions (1-based)
Notes
- Creates a multi-valued index mapping key values to arrays of positions
- Each key maps to an array of all positions with that key value
- Returns 1-based array indices sorted by position
- NULL keys are excluded from the index
- Useful for one-to-many lookups with ELEMENTS_AT_KEY
- Preserves all occurrences of duplicate keys
- Use INDEX_UNIQUE for keys with single values