1
0

geoline-aggregation.asciidoc 2.9 KB

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