query-dsl.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. [[query-dsl]]
  2. = Query DSL
  3. [partintro]
  4. --
  5. Elasticsearch provides a full Query DSL (Domain Specific Language) based on JSON to define queries.
  6. Think of the Query DSL as an AST (Abstract Syntax Tree) of queries, consisting of two types of
  7. clauses:
  8. Leaf query clauses::
  9. Leaf query clauses look for a particular value in a particular field, such as the
  10. <<query-dsl-match-query,`match`>>, <<query-dsl-term-query,`term`>> or
  11. <<query-dsl-range-query,`range`>> queries. These queries can be used
  12. by themselves.
  13. Compound query clauses::
  14. Compound query clauses wrap other leaf *or* compound queries and are used to combine
  15. multiple queries in a logical fashion (such as the
  16. <<query-dsl-bool-query,`bool`>> or <<query-dsl-dis-max-query,`dis_max`>> query),
  17. or to alter their behaviour (such as the
  18. <<query-dsl-constant-score-query,`constant_score`>> query).
  19. Query clauses behave differently depending on whether they are used in
  20. <<query-filter-context,query context or filter context>>.
  21. [[query-dsl-allow-expensive-queries]]
  22. Allow expensive queries::
  23. Certain types of queries will generally execute slowly due to the way they are implemented, which can affect
  24. the stability of the cluster. Those queries can be categorised as follows:
  25. * Queries that need to do linear scans to identify matches:
  26. ** <<query-dsl-script-query, `script queries`>>
  27. * Queries that have a high up-front cost :
  28. ** <<query-dsl-fuzzy-query,`fuzzy queries`>> (except on <<wildcard-field-type, `wildcard`>> fields)
  29. ** <<query-dsl-regexp-query,`regexp queries`>> (except on <<wildcard-field-type, `wildcard`>> fields)
  30. ** <<query-dsl-prefix-query,`prefix queries`>> (except on <<wildcard-field-type, `wildcard`>> fields or those without <<index-prefixes, `index_prefixes`>>)
  31. ** <<query-dsl-wildcard-query, `wildcard queries`>> (except on <<wildcard-field-type, `wildcard`>> fields)
  32. ** <<query-dsl-range-query, `range queries>> on <<text, `text`>> and <<keyword, `keyword`>> fields
  33. * <<joining-queries, `Joining queries`>>
  34. * Queries on <<prefix-trees, deprecated geo shapes>>
  35. * Queries that may have a high per-document cost:
  36. ** <<query-dsl-script-score-query, `script score queries`>>
  37. ** <<query-dsl-percolate-query, `percolate queries`>>
  38. The execution of such queries can be prevented by setting the value of the `search.allow_expensive_queries`
  39. setting to `false` (defaults to `true`).
  40. --
  41. include::query-dsl/query_filter_context.asciidoc[]
  42. include::query-dsl/compound-queries.asciidoc[]
  43. include::query-dsl/full-text-queries.asciidoc[]
  44. include::query-dsl/geo-queries.asciidoc[]
  45. include::query-dsl/shape-queries.asciidoc[]
  46. include::query-dsl/joining-queries.asciidoc[]
  47. include::query-dsl/match-all-query.asciidoc[]
  48. include::query-dsl/span-queries.asciidoc[]
  49. include::query-dsl/special-queries.asciidoc[]
  50. include::query-dsl/term-level-queries.asciidoc[]
  51. include::query-dsl/minimum-should-match.asciidoc[]
  52. include::query-dsl/multi-term-rewrite.asciidoc[]
  53. include::query-dsl/regexp-syntax.asciidoc[]