regexp-query.asciidoc 1.5 KB

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