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 BY key ) → INDEX sql
| Parameter | Type | Required | Description |
|---|---|---|---|
base | ARRAY<ROW<T>> | Yes | Array of rows to index |
key | FIELD | Yes | Field of the rows 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
- An index stays inside the query: returning it raises UE/INDEX-OUTPUT-NOT-SUPPORTED
Availability
| Status | Backends |
|---|---|
| Not available | mysql |
See also
Examples
FeatureQL
RETURN
-- Every row with the key, in base order. An index stays inside the query: look it up, do not return it
f1 := ELEMENTS_AT_KEY(
INDEX_MULTI(
ARRAY(
ROW(1 AS k, 'a' AS v),
ROW(2 AS k, 'b' AS v),
ROW(1 AS k, 'c' AS v)
) BY k
),
1
)
;Result
| f1 VARBINARY |
|---|
| [{k: 1, v: a}, {k: 1, v: c}] |
On this page