mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
[DOCS] Adds note about escaping backslashes in regex (#89276)
* [DOCS] Adds note about escaping backslashes in regex * Fix typo * Simplify example
This commit is contained in:
parent
03f3c8119a
commit
f2257cae89
1 changed files with 32 additions and 1 deletions
|
@ -38,6 +38,37 @@ backslash or surround it with double quotes. For example:
|
|||
"john@smith.com" # renders as 'john@smith.com'
|
||||
....
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
|
||||
The backslash is an escape character in both JSON strings and regular
|
||||
expressions. You need to escape both backslashes in a query, unless you use a
|
||||
language client, which takes care of this. For example, the string `a\b` needs
|
||||
to be indexed as `"a\\b"`:
|
||||
|
||||
[source,console]
|
||||
--------------------------------------------------
|
||||
PUT my-index-000001/_doc/1
|
||||
{
|
||||
"my_field": "a\\b"
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
This document matches the following `regexp` query:
|
||||
|
||||
[source,console]
|
||||
--------------------------------------------------
|
||||
GET my-index-000001/_search
|
||||
{
|
||||
"query": {
|
||||
"regexp": {
|
||||
"my_field.keyword": "a\\\\.*"
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
//TEST[continued]
|
||||
====
|
||||
|
||||
[discrete]
|
||||
[[regexp-standard-operators]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue