geoline-aggregation.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. [role="xpack"]
  2. [testenv="gold"]
  3. [[search-aggregations-metrics-geo-line]]
  4. === Geo-Line Aggregation
  5. ++++
  6. <titleabbrev>Geo-Line</titleabbrev>
  7. ++++
  8. The `geo_line` aggregation aggregates all `geo_point` values within a bucket into a LineString ordered
  9. by the chosen `sort` field. This `sort` can be a date field, for example. The bucket returned is a valid
  10. https://tools.ietf.org/html/rfc7946#section-3.2[GeoJSON Feature] representing the line geometry.
  11. [source,console,id=search-aggregations-metrics-geo-line-simple]
  12. ----
  13. PUT test
  14. {
  15. "mappings": {
  16. "dynamic": "strict",
  17. "_source": {
  18. "enabled": false
  19. },
  20. "properties": {
  21. "my_location": {
  22. "type": "geo_point"
  23. },
  24. "group": {
  25. "type": "keyword"
  26. },
  27. "@timestamp": {
  28. "type": "date"
  29. }
  30. }
  31. }
  32. }
  33. POST /test/_bulk?refresh
  34. {"index": {}}
  35. {"my_location": {"lat":37.3450570, "lon": -122.0499820}, "@timestamp": "2013-09-06T16:00:36"}
  36. {"index": {}}
  37. {"my_location": {"lat": 37.3451320, "lon": -122.0499820}, "@timestamp": "2013-09-06T16:00:37Z"}
  38. {"index": {}}
  39. {"my_location": {"lat": 37.349283, "lon": -122.0505010}, "@timestamp": "2013-09-06T16:00:37Z"}
  40. POST /test/_search?filter_path=aggregations
  41. {
  42. "aggs": {
  43. "line": {
  44. "geo_line": {
  45. "point": {"field": "my_location"},
  46. "sort": {"field": "@timestamp"}
  47. }
  48. }
  49. }
  50. }
  51. ----
  52. Which returns:
  53. [source,js]
  54. ----
  55. {
  56. "aggregations": {
  57. "line": {
  58. "type" : "Feature",
  59. "geometry" : {
  60. "type" : "LineString",
  61. "coordinates" : [
  62. [
  63. -122.049982,
  64. 37.345057
  65. ],
  66. [
  67. -122.050501,
  68. 37.349283
  69. ],
  70. [
  71. -122.049982,
  72. 37.345132
  73. ]
  74. ]
  75. },
  76. "properties" : {
  77. "complete" : true
  78. }
  79. }
  80. }
  81. }
  82. ----
  83. // TESTRESPONSE
  84. [[search-aggregations-metrics-geo-line-options]]
  85. ==== Options
  86. `point`::
  87. (Required)
  88. This option specifies the name of the `geo_point` field
  89. Example usage configuring `my_location` as the point field:
  90. [source,js]
  91. ----
  92. "point": {
  93. "field": "my_location"
  94. }
  95. ----
  96. // NOTCONSOLE
  97. `sort`::
  98. (Required)
  99. This option specifies the name of the numeric field to use as the sort key
  100. for ordering the points
  101. Example usage configuring `@timestamp` as the sort key:
  102. [source,js]
  103. ----
  104. "point": {
  105. "field": "@timestamp"
  106. }
  107. ----
  108. // NOTCONSOLE
  109. `include_sort`::
  110. (Optional, boolean, default: `false`)
  111. This option includes, when true, an additional array of the sort values in the
  112. feature properties.
  113. `sort_order`::
  114. (Optional, string, default: `"ASC"`)
  115. This option accepts one of two values: "ASC", "DESC".
  116. The line is sorted in ascending order by the sort key when set to "ASC", and in descending
  117. with "DESC".
  118. `size`::
  119. (Optional, integer, default: `10000`)
  120. The maximum length of the line represented in the aggregation. Valid sizes are
  121. between one and 10000.