Skip to content

Commit 5252995

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

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

docs/reference/ingest.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -770,10 +770,10 @@ PUT _ingest/pipeline/my-pipeline
770770
}
771771
----
772772

773-
If the static `script.painless.regex.enabled` cluster setting is enabled, you
774-
can use regular expressions in your `if` condition scripts. For supported
775-
syntax, see the {painless}/painless-regexes.html[Painless regexes]
776-
documentation.
773+
If the <<script-painless-regex-enabled,`script.painless.regex.enabled`>> cluster
774+
setting is enabled, you can use regular expressions in your `if` condition
775+
scripts. For supported syntax, see {painless}/painless-regexes.html[Painless
776+
regular expressions].
777777

778778
TIP: If possible, avoid using regular expressions. Expensive regular expressions
779779
can slow indexing speeds.

docs/reference/modules/indices/circuit_breaker.asciidoc

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

0 commit comments

Comments
 (0)