ES|QL index optionsedit

The OPTIONS directive of the FROM command allows configuring the way ES|QL accesses the data to be queried. The argument passed to this directive is a comma-separated list of option name-value pairs, with the option name and the corresponding value double-quoted.

FROM index_pattern [OPTIONS "option1"="value1"[,...[,"optionN"="valueN"]]]

These options can only be provided as part of a FROM command, and they apply to all the indices provided or matched by an index pattern.

The option names and their values are the same as used by the Search API, however note that the default values may differ.

The currently supported options are:

allow_no_indices

(Optional, Boolean) If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar.

Defaults to true.

ignore_unavailable

(Optional, Boolean) If false, the request returns an error if it targets a missing or closed index.

Defaults to true.

preference

(Optional, string) Nodes and shards used for the search. By default, Elasticsearch selects from eligible nodes and shards using adaptive replica selection, accounting for allocation awareness.

Valid values for preference
_only_local
Run the search only on shards on the local node.
_local
If possible, run the search on shards on the local node. If not, select shards using the default method.
_only_nodes:<node-id>,<node-id>
Run the search on only the specified nodes IDs. If suitable shards exist on more than one selected node, use shards on those nodes using the default method. If none of the specified nodes are available, select shards from any available node using the default method.
_prefer_nodes:<node-id>,<node-id>
If possible, run the search on the specified nodes IDs. If not, select shards using the default method.
_shards:<shard>,<shard>
Run the search only on the specified shards. You can combine this value with other preference values. However, the _shards value must come first. For example: _shards:2,3|_local.
<custom-string>
Any string that does not start with _. If the cluster state and selected shards do not change, searches using the same <custom-string> value are routed to the same shards in the same order.

Examples

  FROM employees OPTIONS "allow_no_indices"="false","preference"="_local"
| SORT emp_no
| EVAL hire_double = to_double(hire_date)
| KEEP emp_no, hire_date, hire_double
| LIMIT 3
emp_no:integer hire_date:date hire_double:double

10001

1986-06-26T00:00:00.000Z

5.20128E11

10002

1985-11-21T00:00:00.000Z

5.013792E11

10003

1986-08-28T00:00:00.000Z

5.255712E11