_query-template.asciidoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. ////
  2. This is a template for query DSL reference documentation.
  3. To document a new query type, copy this file, remove comments like this, and
  4. replace "sample" with the appropriate query name.
  5. Ensure the new query docs are linked and included in
  6. docs/reference/query-dsl.asciidoc
  7. ////
  8. [[query-dsl-sample-query]]
  9. === Sample query
  10. ++++
  11. <titleabbrev>Sample</titleabbrev>
  12. ++++
  13. ////
  14. INTRO
  15. Include a brief, 1-2 sentence description.
  16. ////
  17. Does a cool thing. For example, it matches `x` to `y`.
  18. [[sample-query-ex-request]]
  19. ==== Example request
  20. ////
  21. Basic example of a search request consisting of only this query.
  22. Guidelines
  23. ***************************************
  24. * Don't include the index name in the request path.
  25. * Don't include common parameters, such as `boost`.
  26. * For clarity, use the long version of the request body. You can include a
  27. short request example in the 'Notes' section.
  28. * Ensure // TEST[skip:...] comments are removed.
  29. ***************************************
  30. ////
  31. [source,console]
  32. ----
  33. GET _search
  34. {
  35. "query": {
  36. "sample": {
  37. "foo": "baz",
  38. "bar": true
  39. }
  40. }
  41. }
  42. ----
  43. // TEST[skip: REMOVE THIS COMMENT.]
  44. [[sample-query-params]]
  45. ==== Parameters
  46. ////
  47. Documents each parameter for the query.
  48. Guidelines
  49. ***************************************
  50. * Use a definition list.
  51. * End each definition with a period.
  52. * Include whether the parameter is Optional or Required and the data type.
  53. * Include default values as the last sentence of the first paragraph.
  54. * Include a range of valid values, if applicable.
  55. * If the parameter requires a specific delimiter for multiple values, say so.
  56. * If the parameter supports wildcards, ditto.
  57. * For large or nested objects, consider linking to a separate definition list.
  58. ***************************************
  59. ////
  60. `foo`::
  61. (Required, string)
  62. A cool thing.
  63. `bar`::
  64. (Optional, string)
  65. If `true`, does a cool thing.
  66. Defaults to `false`.
  67. [[sample-query-notes]]
  68. ==== Notes
  69. ////
  70. Contains extra information about the query, including:
  71. * Additional examples for parameters or short request bodies.
  72. * Tips or advice for using the query.
  73. Guidelines
  74. ***************************************
  75. * For longer sections, consider using the `[%collapsible] macro.
  76. * Ensure // TEST[skip:...] comments are removed.
  77. ***************************************
  78. ////
  79. ===== Avoid using the `sample` query for `text` fields
  80. By default, {es} changes the values of `text` fields during analysis. For
  81. example, ...
  82. ===== Using the `sample` query on time-series data
  83. You can use the `sample` query to perform searches on time-series data.
  84. For example:
  85. [source,console]
  86. ----
  87. GET my_time_series_index/_search
  88. {
  89. "query": {
  90. "sample": {
  91. "foo": "baz",
  92. "bar": false
  93. }
  94. }
  95. }
  96. ----
  97. // TEST[skip: REMOVE THIS COMMENT.]