Skip to content

Commit cafc5e0

Browse files
authored
[DOCS] Document regex circuit breaker (#76048) (#76132)
Documents the `script.painless.regex.enabled` and `script.painless.regex.limit-factor` cluster settings. Relates to #63029. Closes #75199.
1 parent 5ed9d6f commit cafc5e0

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

docs/reference/ingest/ingest-node.asciidoc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -582,15 +582,12 @@ template for all indexes that hold data that needs pre-index processing.
582582

583583
[[conditionals-with-regex]]
584584
=== Conditionals with the Regular Expressions
585-
The `if` conditional is implemented as a Painless script, which requires
586-
{painless}//painless-regexes.html[explicit support for regular expressions].
587585

588-
`script.painless.regex.enabled: true` must be set in `elasticsearch.yml` to use regular
589-
expressions in the `if` condition.
590-
591-
If regular expressions are enabled, operators such as `=~` can be used against a `/pattern/` for conditions.
592-
593-
For example:
586+
The `if` conditional is implemented as a Painless script. If the
587+
<<script-painless-regex-enabled,`script.painless.regex.enabled`>> cluster
588+
setting is enabled, you can use regular expressions in your `if` condition
589+
scripts. For other supported syntax, see
590+
{painless}/painless-regexes.html[Painless regular expressions].
594591

595592
[source,console]
596593
--------------------------------------------------

docs/reference/modules/indices/circuit_breaker.asciidoc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,41 @@ documentation for more information.
129129
Limit for the number of unique dynamic scripts within a certain interval
130130
that are allowed to be compiled for a given context. Defaults to `75/5m`,
131131
meaning 75 every 5 minutes.
132+
133+
[[regex-circuit-breaker]]
134+
[discrete]
135+
==== Regex circuit breaker
136+
137+
Poorly written regular expressions can degrade cluster stability and
138+
performance. The regex circuit breaker limits the use and complexity of
139+
{painless}/painless-regexes.html[regex in Painless scripts].
140+
141+
[[script-painless-regex-enabled]]
142+
`script.painless.regex.enabled`::
143+
(<<static-cluster-setting,Static>>) Enables regex in Painless scripts. Accepts:
144+
145+
`limit` (Default):::
146+
Enables regex but limits complexity using the
147+
<<script-painless-regex-limit-factor,`script.painless.regex.limit-factor`>>
148+
cluster setting.
149+
150+
`true`:::
151+
Enables regex with no complexity limits. Disables the regex circuit breaker.
152+
153+
`false`:::
154+
Disables regex. Any Painless script containing a regular expression returns an
155+
error.
156+
157+
[[script-painless-regex-limit-factor]]
158+
`script.painless.regex.limit-factor`::
159+
(<<static-cluster-setting,Static>>) Limits the number of characters a regular
160+
expression in a Painless script can consider. {es} calculates this limit by
161+
multiplying the setting value by the script input's character length.
162+
+
163+
For example, the input `foobarbaz` has a character length of `9`. If
164+
`script.painless.regex.limit-factor` is `6`, a regular expression on `foobarbaz`
165+
can consider up to 54 (9 * 6) characters. If the expression exceeds this limit,
166+
it triggers the regex circuit breaker and returns an error.
167+
+
168+
{es} only applies this limit if
169+
<<script-painless-regex-enabled,`script.painless.regex.enabled`>> is `limit`.

0 commit comments

Comments
 (0)