1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
[[query-dsl-regexp-query]]
=== Regexp Query
The `regexp` query allows you to use regular expression term queries.
See <<regexp-syntax>> for details of the supported regular expression language.
*Note*: The performance of a `regexp` query heavily depends on the
regular expression chosen. Matching everything like `.*` is very slow as
well as using lookaround regular expressions. If possible, you should
try to use a long prefix before your regular expression starts. Wildcard
matchers like `.*?+` will mostly lower performance.
[source,js]
--------------------------------------------------
{
"regexp":{
"name.first": "s.*y"
}
}
--------------------------------------------------
Boosting is also supported
[source,js]
--------------------------------------------------
{
"regexp":{
"name.first":{
"value":"s.*y",
"boost":1.2
}
}
}
--------------------------------------------------
You can also use special flags
[source,js]
--------------------------------------------------
{
"regexp":{
"name.first": "s.*y",
"flags" : "INTERSECTION|COMPLEMENT|EMPTY"
}
}
--------------------------------------------------
Possible flags are `ALL`, `ANYSTRING`, `AUTOMATON`, `COMPLEMENT`,
`EMPTY`, `INTERSECTION`, `INTERVAL`, or `NONE`. Please check the
http://lucene.apache.org/core/4_3_0/core/index.html?org%2Fapache%2Flucene%2Futil%2Fautomaton%2FRegExp.html[Lucene
documentation] for their meaning
include::regexp-syntax.asciidoc[]
|