You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|The ``mvexpand`` command expands each value in a multivalue (array) field into a separate row, similar to Splunk's `mvexpand` command.
15
-
|For each document, every value in the specified field is returned as a new row. This is especially useful for log analytics and data exploration involving array fields.
16
-
17
-
|Key features of ``mvexpand``:
18
-
- Expands array fields into multiple rows, one per value.
19
-
- Supports an optional ``limit`` parameter to restrict the number of expanded values per document.
20
-
- Handles empty, null, and non-array fields gracefully.
21
-
- Works as a streaming/distributable command for performance and scalability.
14
+
|The ``mvexpand`` command expands each value in a multivalue (array) field into a separate row,
15
+
|similar to Splunk's ``mvexpand`` command. For each document, every element in the specified
16
+
|array field is returned as a new row.
22
17
23
18
Syntax
24
19
======
25
-
mvexpand <field> [limit=<int>]
26
-
27
-
* **field**: The multivalue (array) field to expand. (Required)
28
-
* **limit**: Maximum number of values per document to expand. (Optional)
29
-
30
-
Usage
31
-
=====
32
-
Basic expansion::
33
-
34
-
source=logs | mvexpand tags
35
-
36
-
Expansion with limit::
37
-
38
-
source=docs | mvexpand ids limit=3
20
+
``mvexpand <field> [limit=<int>]``
39
21
40
-
Limitations
41
-
===========
42
-
- Only one field can be expanded per mvexpand command.
43
-
- For non-array fields, the value is returned as-is.
44
-
- For empty or null arrays, no rows are returned.
45
-
- Large arrays may be subject to resource/memory limits; exceeding them results in an error or warning.
22
+
* ``field``: The multivalue (array) field to expand. (Required)
23
+
* ``limit``: Maximum number of values per document to expand. (Optional)
46
24
47
-
Output ordering and default limit
48
-
--------------------------------
49
-
If no `limit` is specified, mvexpand expands all elements in the array (there is no implicit per-document cap). Elements are emitted in the same order they appear in the array (array iteration order). If the underlying field does not provide a defined order, the output order is undefined. Use `limit` to bound the number of expanded rows per document and to avoid resource issues on very large arrays.
50
-
51
-
Examples and Edge Cases
52
-
=======================
53
-
54
-
Example 1: Basic Expansion
25
+
Notes about these doctests
55
26
--------------------------
56
-
Expand all values from an array field.
57
-
58
-
Input document::
59
-
60
-
{ "tags": ["error", "warning", "info"] }
61
-
62
-
PPL query::
27
+
- The tests below target a single, deterministic document by using ``where case='<name>'`` so the doctests are stable.
28
+
- The test index name used in these examples is ``mvexpand_logs``.
63
29
64
-
source=logs | mvexpand tags
30
+
Example 1: Basic Expansion (single document)
31
+
-------------------------------------------
32
+
Input document (case "basic") contains three tag values.
If an array is very large it can trigger engine or cluster resource limits and the query can fail with an error. There is no mvexpand-specific configuration. Instead, limits that can cause a query to be terminated are enforced at the node / engine level and by SQL/PPL query controls.
160
-
161
-
- OpenSearch node protections (for example, heap / query memory limits such as plugins.query.memory_limit) can terminate queries that exceed configured memory budgets.
162
-
- SQL/PPL execution limits (timeouts, request/response size limits, and engine memory budgets) also apply to queries that use mvexpand.
163
-
- Note: in the current Calcite-based engine, circuit-breaking protections are applied primarily to the index scan operator; protections for other operators (including some operators used internally to implement mvexpand) are under research. Do not assume operator-level circuit breaking will fully protect mvexpand in all cases.
88
+
+------------+
89
+
| tags.value |
90
+
|------------|
91
+
| error |
92
+
+------------+
164
93
165
-
To avoid failures when expanding large arrays:
166
-
- Use mvexpand's limit parameter to bound the number of expanded values per document (for example: mvexpand field limit=1000).
167
-
- Reduce the input size before expanding (filter with where, project only needed fields).
168
-
- Tune cluster and SQL/PPL execution settings (circuit breakers, request/response size, timeouts, memory limits) appropriate for your deployment.
0 commit comments