INDEX_MULTI()

All functions > ARRAY OF ROWS > INDEX_MULTI()

Returns an index multi computed from the given array and key.

Signatures

Returns: Map from key values to arrays of positions (1-based)

INDEX_MULTI(base: ARRAY<ROW<T>>, key: FIELD) → INDEX
sql
ParameterTypeRequiredDescription
baseARRAY<ROW<T>>YesArray of rows to index
keyFIELDYesField name to use as lookup key

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

Examples

FeatureQL
SELECT
    f1 := INDEX_MULTI(ARRAY[ROW(1 AS k, 'a' AS v), ROW(1 AS k, 'b' AS v)] BY k) -- Map each key to all 1-based positions with that key (equiv skipped: MAP has no FeatureQL literal)
;
Result
f1 VARCHAR
{1: [1, 2]}

Last update at: 2026/05/26 17:22:09