2013-08-28 19:24:34 -04:00
|
|
|
[[query-dsl-regexp-query]]
|
|
|
|
=== Regexp Query
|
|
|
|
|
|
|
|
The `regexp` query allows you to use regular expression term queries.
|
2013-10-07 08:42:13 -04:00
|
|
|
See <<regexp-syntax>> for details of the supported regular expression language.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
*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
|
|
|
|
|
2013-10-07 08:42:13 -04:00
|
|
|
|
|
|
|
include::regexp-syntax.asciidoc[]
|