File: regexp-query.asciidoc

package info (click to toggle)
elasticsearch 1.0.3%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 37,220 kB
  • sloc: java: 365,486; xml: 1,258; sh: 714; python: 505; ruby: 354; perl: 134; makefile: 41
file content (54 lines) | stat: -rw-r--r-- 1,520 bytes parent folder | download
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[]