search-vector-tile-api.asciidoc 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911
  1. [[search-vector-tile-api]]
  2. === Vector tile search API
  3. ++++
  4. <titleabbrev>Vector tile search</titleabbrev>
  5. ++++
  6. Searches a vector tile for geospatial values. Returns results as a binary
  7. https://docs.mapbox.com/vector-tiles/specification[Mapbox vector tile].
  8. ////
  9. [source,console]
  10. ----
  11. PUT my-index
  12. {
  13. "mappings": {
  14. "properties": {
  15. "my-geo-field": {
  16. "type": "geo_point"
  17. }
  18. }
  19. }
  20. }
  21. PUT my-index/_doc/0?refresh
  22. {
  23. "my-geo-field": "POINT (-122.0863176 37.3864953)"
  24. }
  25. ----
  26. ////
  27. [source,console]
  28. ----
  29. GET my-index/_mvt/my-geo-field/15/5271/12710
  30. ----
  31. // TEST[continued]
  32. [[search-vector-tile-api-request]]
  33. ==== {api-request-title}
  34. `GET <target>/_mvt/<field>/<zoom>/<x>/<y>`
  35. `POST <target>/_mvt/<field>/<zoom>/<x>/<y>`
  36. [[search-vector-tile-api-prereqs]]
  37. ==== {api-prereq-title}
  38. * Before using this API, you should be familiar with the
  39. https://github.com/mapbox/vector-tile-spec[Mapbox vector tile specification].
  40. * If the {es} {security-features} are enabled, you must have the `read`
  41. <<privileges-list-indices,index privilege>> for the target data stream, index,
  42. or alias. For cross-cluster search, see <<cross-cluster-configuring>>.
  43. [[search-vector-tile-api-path-params]]
  44. ==== {api-path-parms-title}
  45. `<target>`::
  46. (Required, string) Comma-separated list of data streams, indices, or aliases to
  47. search. Supports wildcards (`*`). To search all data streams and indices, omit
  48. this parameter or use `*` or `_all`.
  49. +
  50. To search a remote cluster, use the `<cluster>:<target>` syntax. See
  51. <<modules-cross-cluster-search>>.
  52. `<field>`::
  53. (Required, string) Field containing geospatial values to return. Must be a
  54. <<geo-point,`geo_point`>> or <<geo-shape,`geo_shape`>> field. The field must
  55. have <<doc-values,doc values>> enabled. Cannot be a nested field.
  56. +
  57. NOTE: Vector tiles do not natively support geometry collections. For
  58. `geometrycollection` values in a `geo_shape` field, the API returns a `hits`
  59. layer feature for each element of the collection. This behavior may change may
  60. change in a future release.
  61. `<zoom>`::
  62. (Required, integer) Zoom level for the vector tile to search. Accepts `0`-`29`.
  63. `<x>`::
  64. (Required, integer) X coordinate for the vector tile to search.
  65. `<y>`::
  66. (Required, integer) Y coordinate for the vector tile to search.
  67. [[search-vector-tile-api-desc]]
  68. ==== {api-description-title}
  69. Internally, {es} translates a vector tile search API request into a
  70. <<search-search,search>> containing:
  71. * A <<query-dsl-geo-bounding-box-query,`geo_bounding_box`>> query on the
  72. `<field>`. The query uses the `<zoom>/<x>/<y>` tile as a bounding box.
  73. * A <<search-aggregations-bucket-geotilegrid-aggregation,`geotile_grid`>> or
  74. <<search-aggregations-bucket-geohexgrid-aggregation,`geohex_grid`>> aggregation
  75. on the `<field>`. The `grid_agg` parameter determines the aggregation type. The
  76. aggregation uses the `<zoom>/<x>/<y>` tile as a bounding box.
  77. * Optionally, a
  78. <<search-aggregations-metrics-geobounds-aggregation,`geo_bounds`>> aggregation
  79. on the `<field>`. The search only includes this aggregation if the
  80. `exact_bounds` parameter is `true`.
  81. * If the optional parameter `with_labels` is true, the internal search will include
  82. a dynamic runtime field that calls the `getLabelPosition` function of the geometry doc value.
  83. This enables the generation of new point features containing suggested geometry labels,
  84. so that, for example, multi-polygons will have only one label.
  85. For example, {es} may translate a vector tile search API request with a
  86. `grid_agg` argument of `geotile` and an `exact_bounds` argument of `true`
  87. into the following search:
  88. [source,console]
  89. ----
  90. GET my-index/_search
  91. {
  92. "size": 10000,
  93. "query": {
  94. "geo_bounding_box": {
  95. "my-geo-field": {
  96. "top_left": {
  97. "lat": -40.979898069620134,
  98. "lon": -45
  99. },
  100. "bottom_right": {
  101. "lat": -66.51326044311186,
  102. "lon": 0
  103. }
  104. }
  105. }
  106. },
  107. "aggregations": {
  108. "grid": {
  109. "geotile_grid": {
  110. "field": "my-geo-field",
  111. "precision": 11,
  112. "size": 65536,
  113. "bounds": {
  114. "top_left": {
  115. "lat": -40.979898069620134,
  116. "lon": -45
  117. },
  118. "bottom_right": {
  119. "lat": -66.51326044311186,
  120. "lon": 0
  121. }
  122. }
  123. }
  124. },
  125. "bounds": {
  126. "geo_bounds": {
  127. "field": "my-geo-field",
  128. "wrap_longitude": false
  129. }
  130. }
  131. }
  132. }
  133. ----
  134. // TEST[continued]
  135. The API returns results as a binary
  136. https://github.com/mapbox/vector-tile-spec[Mapbox vector tile]. Mapbox vector
  137. tiles are encoded as https://github.com/protocolbuffers/protobuf[Google
  138. Protobufs (PBF)]. By default, the tile contains three layers:
  139. * A `hits` layer containing a feature for each `<field>` value matching the
  140. `geo_bounding_box` query.
  141. * An `aggs` layer containing a feature for each cell of the `geotile_grid` or
  142. `geohex_grid`. The layer only contains features for cells with matching data.
  143. * A `meta` layer containing:
  144. ** A feature containing a bounding box. By default, this is the bounding box of
  145. the tile.
  146. ** Value ranges for any sub-aggregations on the `geotile_grid` or `geohex_grid`.
  147. ** Metadata for the search.
  148. The API only returns features that can display at its zoom level. For example,
  149. if a polygon feature has no area at its zoom level, the API omits it.
  150. The API returns errors as UTF-8 encoded JSON.
  151. [role="child_attributes"]
  152. [[search-vector-tile-api-query-params]]
  153. ==== {api-query-parms-title}
  154. IMPORTANT: You can specify several options for this API as either a query
  155. parameter or request body parameter. If you specify both parameters, the query
  156. parameter takes precedence.
  157. // tag::exact-bounds[]
  158. `exact_bounds`::
  159. (Optional, Boolean)
  160. If `false`, the `meta` layer's feature is the bounding box of the tile. Defaults
  161. to `false`.
  162. +
  163. If `true`, the `meta` layer's feature is a bounding box resulting from a
  164. <<search-aggregations-metrics-geobounds-aggregation,`geo_bounds`>> aggregation.
  165. The aggregation runs on `<field>` values that intersect the `<zoom>/<x>/<y>`
  166. tile with `wrap_longitude` set to `false`. The resulting bounding box may be
  167. larger than the vector tile.
  168. // end::exact-bounds[]
  169. // tag::extent-param[]
  170. `extent`::
  171. (Optional, integer) Size, in pixels, of a side of the tile. Vector tiles are
  172. square with equal sides. Defaults to `4096`.
  173. // end::extent-param[]
  174. // tag::buffer-param[]
  175. `buffer`::
  176. (Optional, integer) Size, in pixels, of a clipping buffer outside the tile.
  177. This allows renderers to avoid outline artifacts from geometries that extend past the extent of the tile.
  178. Defaults to `5`.
  179. // end::buffer-param[]
  180. // tag::grid-agg[]
  181. `grid_agg`::
  182. (Optional, string) Aggregation used to create a grid for the `<field>`.
  183. +
  184. .Valid values for `grid_agg`
  185. [%collapsible%open]
  186. ====
  187. `geotile` (Default)::
  188. <<search-aggregations-bucket-geotilegrid-aggregation,`geotile_grid`>>
  189. aggregation.
  190. `geohex`::
  191. <<search-aggregations-bucket-geohexgrid-aggregation,`geohex_grid`>> aggregation.
  192. If you specify this value, the `<field>` must be a <<geo-point,`geo_point`>>
  193. field.
  194. ====
  195. // end::grid-agg[]
  196. // tag::grid-precision[]
  197. `grid_precision`::
  198. (Optional, integer) Precision level for cells in the `grid_agg`. Accepts
  199. `0`-`8`. Defaults to `8`. If `0`, results don't include the `aggs` layer.
  200. +
  201. .Grid precision for `geotile`
  202. [%collapsible%open]
  203. ====
  204. For a `grid_agg` of `geotile`, you can use cells in the `aggs` layer as tiles
  205. for lower zoom levels. `grid_precision` represents the additional zoom levels
  206. available through these cells. The final precision is computed by as
  207. follows:
  208. `<zoom> + grid_precision`
  209. For example, if `<zoom>` is `7` and `grid_precision` is `8`, then the
  210. `geotile_grid` aggregation will use a precision of `15`. The maximum final
  211. precision is `29`.
  212. The `grid_precision` also determines the number of cells for the grid as
  213. follows:
  214. `(2^grid_precision) x (2^grid_precision)`
  215. For example, a value of `8` divides the tile into a grid of 256 x 256 cells. The
  216. `aggs` layer only contains features for cells with matching data.
  217. ====
  218. +
  219. .Grid precision for `geohex`
  220. [%collapsible%open]
  221. ====
  222. For a `grid_agg` of `geohex`, {es} uses `<zoom>` and `grid_precision` to
  223. calculate a final precision as follows:
  224. `<zoom> + grid_precision`
  225. This precision determines the https://h3geo.org/docs/core-library/restable[H3
  226. resolution of the hexagonal cells] produced by the `geohex` aggregation. The
  227. following table maps the H3 resolution for each precision.
  228. For example, if `<zoom>` is `3` and `grid_precision` is `3`, the precision is
  229. `6`. At a precision of `6`, hexagonal cells have an H3 resolution of `2`. If
  230. `<zoom>` is `3` and `grid_precision` is `4`, the precision is `7`. At a
  231. precision of `7`, hexagonal cells have an H3 resolution of `3`.
  232. [cols="<,<,<,<,<",options="header",]
  233. |====
  234. |Precision | Unique tile bins| H3 resolution| Unique hex bins | Ratio
  235. |1 |4 |0 |122 |30.5
  236. |2 |16 |0 |122 |7.625
  237. |3 |64 |1 |842 |13.15625
  238. |4 |256 |1 |842 |3.2890625
  239. |5 |1024 |2 |5882 |5.744140625
  240. |6 |4096 |2 |5882 |1.436035156
  241. |7 |16384 |3 |41162 |2.512329102
  242. |8 |65536 |3 |41162 |0.6280822754
  243. |9 |262144 |4 |288122 |1.099098206
  244. |10 |1048576 |4 |288122 |0.2747745514
  245. |11 |4194304 |5 |2016842 |0.4808526039
  246. |12 |16777216 |6 |14117882 |0.8414913416
  247. |13 |67108864 |6 |14117882 |0.2103728354
  248. |14 |268435456 |7 |98825162 |0.3681524172
  249. |15 |1073741824 |8 |691776122 |0.644266719
  250. |16 |4294967296 |8 |691776122 |0.1610666797
  251. |17 |17179869184 |9 |4842432842 |0.2818666889
  252. |18 |68719476736 |10 |33897029882 |0.4932667053
  253. |19 |274877906944 |11 |237279209162 |0.8632167343
  254. |20 |1099511627776 |11 |237279209162 |0.2158041836
  255. |21 |4398046511104 |12 |1660954464122 |0.3776573213
  256. |22 |17592186044416 |13 |11626681248842 |0.6609003122
  257. |23 |70368744177664 |13 |11626681248842 |0.165225078
  258. |24 |281474976710656 |14 |81386768741882 |0.2891438866
  259. |25 |1125899906842620 |15 |569707381193162 |0.5060018015
  260. |26 |4503599627370500 |15 |569707381193162 |0.1265004504
  261. |27 |18014398509482000 |15 |569707381193162 |0.03162511259
  262. |28 |72057594037927900 |15 |569707381193162 |0.007906278149
  263. |29 |288230376151712000 |15 |569707381193162 |0.001976569537
  264. |====
  265. Hexagonal cells don't align perfectly on a vector tile. Some cells may intersect
  266. more than one vector tile. To compute the H3 resolution for each precision, {es}
  267. compares the average density of hexagonal bins at each resolution with the
  268. average density of tile bins at each zoom level. {es} uses the H3 resolution
  269. that is closest to the corresponding `geotile` density.
  270. ====
  271. // end::grid-precision[]
  272. // tag::grid-type[]
  273. `grid_type`::
  274. (Optional, string) Determines the geometry type for features in the `aggs`
  275. layer. In the `aggs` layer, each feature represents a cell in the grid.
  276. +
  277. .Valid values for `grid_type`
  278. [%collapsible%open]
  279. ====
  280. `grid` (Default)::
  281. Each feature is a `Polygon` of the cell's geometry. For a `grid_agg` of
  282. `geotile`, the feature is the cell's bounding box. For a `grid_agg` of
  283. `geohex`, the feature is the hexagonal cell's boundaries.
  284. `point`::
  285. Each feature is a `Point` that's the centroid of the cell.
  286. `centroid`::
  287. Each feature is a `Point` that's the centroid of the data within the cell. For
  288. complex geometries, the actual centroid may be outside the cell. In these cases,
  289. the feature is set to the closest point to the centroid inside the cell.
  290. ====
  291. // end::grid-type[]
  292. // tag::size[]
  293. `size`::
  294. (Optional, integer) Maximum number of features to return in the `hits` layer.
  295. Accepts `0`-`10000`. Defaults to `10000`. If `0`, results don't include the
  296. `hits` layer.
  297. // end::size[]
  298. // tag::track_total_hits[]
  299. `track_total_hits`::
  300. (Optional, integer or Boolean)
  301. Number of hits matching the query to count accurately. Defaults to `10000`.
  302. +
  303. If `true`, the exact number of hits is returned at the cost of some performance.
  304. If `false`, the response does not include the total number of hits matching the query.
  305. // end::track_total_hits[]
  306. // tag::with_labels[]
  307. `with_labels`::
  308. (Optional, Boolean)
  309. If true, the hits and aggs layers will contain additional point features representing
  310. suggested label positions for the original features.
  311. * `Point` and `MultiPoint` features will have one of the points selected.
  312. * `Polygon` and `MultiPolygon` features will have a single point generated,
  313. either the centroid, if it is within the polygon, or another point within the
  314. polygon selected from the <<geoshape-indexing-approach,sorted triangle-tree>>.
  315. * `LineString` features will likewise provide a roughly central point selected
  316. from the <<geoshape-indexing-approach,triangle-tree>>.
  317. * The aggregation results will provide one central point for each aggregation bucket.
  318. +
  319. All attributes from the original features will also be copied to the new label features.
  320. In addition, the new features will be distinguishable using the tag `_mvt_label_position`.
  321. // end::with_labels[]
  322. [role="child_attributes"]
  323. [[search-vector-tile-api-request-body]]
  324. ==== {api-request-body-title}
  325. `aggs`::
  326. (Optional, <<search-aggregations,aggregation object>>)
  327. <<run-sub-aggs,Sub-aggregations>> for the `grid_agg`. Supports the following
  328. aggregation types:
  329. +
  330. * <<search-aggregations-metrics-avg-aggregation,`avg`>>
  331. * <<search-aggregations-metrics-boxplot-aggregation,`boxplot`>>
  332. * <<search-aggregations-metrics-cardinality-aggregation,`cardinality`>>
  333. * <<search-aggregations-metrics-extendedstats-aggregation,`extended stats`>>
  334. * <<search-aggregations-metrics-max-aggregation,`max`>>
  335. * <<search-aggregations-metrics-median-absolute-deviation-aggregation,`median absolute deviation`>>
  336. * <<search-aggregations-metrics-min-aggregation,`min`>>
  337. * <<search-aggregations-metrics-percentile-aggregation,`percentile`>>
  338. * <<search-aggregations-metrics-percentile-rank-aggregation,`percentile-rank`>>
  339. * <<search-aggregations-metrics-stats-aggregation,`stats`>>
  340. * <<search-aggregations-metrics-sum-aggregation,`sum`>>
  341. * <<search-aggregations-metrics-valuecount-aggregation,`value count`>>
  342. +
  343. The aggregation names can't start with `_mvt_`. The `_mvt_` prefix is reserved
  344. for internal aggregations.
  345. include::search-vector-tile-api.asciidoc[tag=exact-bounds]
  346. include::search-vector-tile-api.asciidoc[tag=extent-param]
  347. include::search-vector-tile-api.asciidoc[tag=buffer-param]
  348. `fields`::
  349. (Optional, array of strings and objects) Fields to return in the `hits` layer.
  350. Supports wildcards (`*`).
  351. +
  352. This parameter does not support fields with <<array,array values>>. Fields with
  353. array values may return inconsistent results.
  354. +
  355. You can specify fields in the array as a string or object.
  356. +
  357. .Properties of `fields` objects
  358. [%collapsible%open]
  359. ====
  360. include::search.asciidoc[tag=fields-param-props]
  361. ====
  362. include::search-vector-tile-api.asciidoc[tag=grid-agg]
  363. include::search-vector-tile-api.asciidoc[tag=grid-precision]
  364. include::search-vector-tile-api.asciidoc[tag=grid-type]
  365. `query`::
  366. (Optional, object) <<query-dsl,Query DSL>> used to filter documents for the
  367. search.
  368. include::{es-repo-dir}/search/search.asciidoc[tag=runtime-mappings-def]
  369. include::search-vector-tile-api.asciidoc[tag=size]
  370. `sort`::
  371. (Optional, array of <<sort-search-results,sort objects>>) Sorts features in the
  372. `hits` layer.
  373. +
  374. By default, the API calculates a bounding box for each feature. It sorts
  375. features based on this box's diagonal length, from longest to shortest.
  376. include::search-vector-tile-api.asciidoc[tag=track_total_hits]
  377. include::search-vector-tile-api.asciidoc[tag=with_labels]
  378. [role="child_attributes"]
  379. [[search-vector-tile-api-response]]
  380. ==== Response
  381. Returned vector tiles contain the following data:
  382. `hits`::
  383. (object) Layer containing results for the `geo_bounding_box` query.
  384. +
  385. .Properties of `hits`
  386. [%collapsible%open]
  387. ====
  388. // tag::extent[]
  389. `extent`::
  390. (integer) Size, in pixels, of a side of the tile. Vector tiles are square with
  391. equal sides.
  392. // end::extent[]
  393. // tag::version[]
  394. `version`::
  395. (integer) Major version number of the
  396. https://github.com/mapbox/vector-tile-spec[Mapbox vector tile specification].
  397. // end::version[]
  398. `features`::
  399. (array of objects) Array of features. Contains a feature for each `<field>`
  400. value that matches the `geo_bounding_box` query.
  401. +
  402. .Properties of `features` objects
  403. [%collapsible%open]
  404. =====
  405. // tag::geometry[]
  406. `geometry`::
  407. (object) Geometry for the feature.
  408. +
  409. .Properties of `geometry`
  410. [%collapsible%open]
  411. ======
  412. `type`::
  413. (string) Geometry type for the feature. Valid values are:
  414. * `UNKNOWN`
  415. * `POINT`
  416. * `LINESTRING`
  417. * `POLYGON`
  418. `coordinates`::
  419. (array of integers or array of arrays) Tile coordinates for the feature.
  420. ======
  421. // end::geometry[]
  422. `properties`::
  423. (object) Properties for the feature.
  424. +
  425. .Properties of `properties`
  426. [%collapsible%open]
  427. ======
  428. `_id`::
  429. (string) Document `_id` for the feature's document.
  430. `_index`::
  431. (string) Name of the index for the feature's document.
  432. `<field>`::
  433. Field value. Only returned for fields in the `fields` parameter.
  434. ======
  435. // tag::feature-type[]
  436. `type`::
  437. (integer) Identifier for the feature's geometry type. Values are:
  438. +
  439. * `1` (`POINT`)
  440. * `2` (`LINESTRING`)
  441. * `3` (`POLYGON`)
  442. // end::feature-type[]
  443. =====
  444. ====
  445. `aggs`::
  446. (object) Layer containing results for the `grid_agg` aggregation and its
  447. sub-aggregations.
  448. +
  449. .Properties of `aggs`
  450. [%collapsible%open]
  451. ====
  452. include::search-vector-tile-api.asciidoc[tag=extent]
  453. include::search-vector-tile-api.asciidoc[tag=version]
  454. `features`::
  455. (array of objects) Array of features. Contains a feature for each cell of the grid.
  456. +
  457. .Properties of `features` objects
  458. [%collapsible%open]
  459. =====
  460. include::search-vector-tile-api.asciidoc[tag=geometry]
  461. `properties`::
  462. (object) Properties for the feature.
  463. +
  464. .Properties of `properties`
  465. [%collapsible%open]
  466. ======
  467. `_count`::
  468. (long) Count of the cell's documents.
  469. `_key`::
  470. (string) Bucket key of the cell in the format `<zoom>/<x>/<y>`.
  471. `<sub-aggregation>.value`::
  472. Sub-aggregation results for the cell. Only returned for sub-aggregations in the
  473. `aggs` parameter.
  474. ======
  475. include::search-vector-tile-api.asciidoc[tag=feature-type]
  476. =====
  477. ====
  478. `meta`::
  479. (object) Layer containing metadata for the request.
  480. +
  481. .Properties of `meta`
  482. [%collapsible%open]
  483. ====
  484. include::search-vector-tile-api.asciidoc[tag=extent]
  485. include::search-vector-tile-api.asciidoc[tag=version]
  486. `features`::
  487. (array of objects) Contains a feature for a bounding box.
  488. +
  489. .Properties of `features` objects
  490. [%collapsible%open]
  491. =====
  492. include::search-vector-tile-api.asciidoc[tag=geometry]
  493. `properties`::
  494. (object) Properties for the feature.
  495. +
  496. .Properties of `properties`
  497. [%collapsible%open]
  498. ======
  499. `_shards.failed`::
  500. (integer) Number of shards that failed to execute the search. See the search
  501. API's <<search-api-shards,`shards`>> response property.
  502. `_shards.skipped`::
  503. (integer) Number of shards that skipped the search. See the search
  504. API's <<search-api-shards,`shards`>> response property.
  505. `_shards.successful`::
  506. (integer) Number of shards that executed the search successfully. See the
  507. search API's <<search-api-shards,`shards`>> response property.
  508. `_shards.total`::
  509. (integer) Total number of shards that required querying, including unallocated
  510. shards. See the search API's <<search-api-shards,`shards`>> response property.
  511. `aggregations._count.avg`::
  512. (float) Average `_count` value for features in the `aggs` layer.
  513. `aggregations._count.count`::
  514. (integer) Number of unique `_count` values for features in the `aggs` layer.
  515. `aggregations._count.max`::
  516. (float) Largest `_count` value for features in the `aggs` layer.
  517. `aggregations._count.min`::
  518. (float) Smallest `_count` value for features in the `aggs` layer.
  519. `aggregations._count.sum`::
  520. (float) Sum of `_count` values for features in the `aggs` layer.
  521. `aggregations.<sub-aggregation>.avg`::
  522. (float) Average value for the sub-aggregation's results.
  523. `aggregations.<agg_name>.count`::
  524. (integer) Number of unique values from the sub-aggregation's results.
  525. `aggregations.<agg_name>.max`::
  526. (float) Largest value from the sub-aggregation's results.
  527. `aggregations.<agg_name>.min`::
  528. (float) Smallest value from the sub-aggregation's results.
  529. `aggregations.<agg_name>.sum`::
  530. (float) Sum of values for the sub-aggregation's results.
  531. `hits.max_score`::
  532. (float) Highest document `_score` for the search's hits.
  533. `hits.total.relation`::
  534. (string) Indicates whether `hits.total.value` is accurate or a lower bound.
  535. Possible values are:
  536. `eq`::: Accurate
  537. `gte`::: Lower bound
  538. `hits.total.value`::
  539. (integer) Total number of hits for the search.
  540. `timed_out`::
  541. (Boolean) If `true`, the search timed out before completion. Results may be
  542. partial or empty.
  543. `took`::
  544. (integer) Milliseconds it took {es} to run the search. See the search API's
  545. <<search-api-took,`took`>> response property.
  546. ======
  547. include::search-vector-tile-api.asciidoc[tag=feature-type]
  548. =====
  549. ====
  550. [[search-vector-tile-api-api-example]]
  551. ==== {api-examples-title}
  552. The following requests create the `museum` index and add several geospatial
  553. `location` values.
  554. [source,console]
  555. ----
  556. PUT museums
  557. {
  558. "mappings": {
  559. "properties": {
  560. "location": {
  561. "type": "geo_point"
  562. },
  563. "name": {
  564. "type": "keyword"
  565. },
  566. "price": {
  567. "type": "long"
  568. },
  569. "included": {
  570. "type": "boolean"
  571. }
  572. }
  573. }
  574. }
  575. POST museums/_bulk?refresh
  576. { "index": { "_id": "1" } }
  577. { "location": "POINT (4.912350 52.374081)", "name": "NEMO Science Museum", "price": 1750, "included": true }
  578. { "index": { "_id": "2" } }
  579. { "location": "POINT (4.901618 52.369219)", "name": "Museum Het Rembrandthuis", "price": 1500, "included": false }
  580. { "index": { "_id": "3" } }
  581. { "location": "POINT (4.914722 52.371667)", "name": "Nederlands Scheepvaartmuseum", "price":1650, "included": true }
  582. { "index": { "_id": "4" } }
  583. { "location": "POINT (4.914722 52.371667)", "name": "Amsterdam Centre for Architecture", "price":0, "included": true }
  584. ----
  585. The following request searches the index for `location` values that intersect
  586. the `13/4207/2692` vector tile.
  587. [source,console]
  588. ----
  589. GET museums/_mvt/location/13/4207/2692
  590. {
  591. "grid_agg": "geotile",
  592. "grid_precision": 2,
  593. "fields": [
  594. "name",
  595. "price"
  596. ],
  597. "query": {
  598. "term": {
  599. "included": true
  600. }
  601. },
  602. "aggs": {
  603. "min_price": {
  604. "min": {
  605. "field": "price"
  606. }
  607. },
  608. "max_price": {
  609. "max": {
  610. "field": "price"
  611. }
  612. },
  613. "avg_price": {
  614. "avg": {
  615. "field": "price"
  616. }
  617. }
  618. }
  619. }
  620. ----
  621. // TEST[continued]
  622. The API returns results as a binary vector tile. When decoded into JSON, the
  623. tile contains the following data:
  624. [source,js]
  625. ----
  626. {
  627. "hits": {
  628. "extent": 4096,
  629. "version": 2,
  630. "features": [
  631. {
  632. "geometry": {
  633. "type": "Point",
  634. "coordinates": [
  635. 3208,
  636. 3864
  637. ]
  638. },
  639. "properties": {
  640. "_id": "1",
  641. "_index": "museums",
  642. "name": "NEMO Science Museum",
  643. "price": 1750
  644. },
  645. "type": 1
  646. },
  647. {
  648. "geometry": {
  649. "type": "Point",
  650. "coordinates": [
  651. 3429,
  652. 3496
  653. ]
  654. },
  655. "properties": {
  656. "_id": "3",
  657. "_index": "museums",
  658. "name": "Nederlands Scheepvaartmuseum",
  659. "price": 1650
  660. },
  661. "type": 1
  662. },
  663. {
  664. "geometry": {
  665. "type": "Point",
  666. "coordinates": [
  667. 3429,
  668. 3496
  669. ]
  670. },
  671. "properties": {
  672. "_id": "4",
  673. "_index": "museums",
  674. "name": "Amsterdam Centre for Architecture",
  675. "price": 0
  676. },
  677. "type": 1
  678. }
  679. ]
  680. },
  681. "aggs": {
  682. "extent": 4096,
  683. "version": 2,
  684. "features": [
  685. {
  686. "geometry": {
  687. "type": "Polygon",
  688. "coordinates": [
  689. [
  690. [
  691. 3072,
  692. 3072
  693. ],
  694. [
  695. 4096,
  696. 3072
  697. ],
  698. [
  699. 4096,
  700. 4096
  701. ],
  702. [
  703. 3072,
  704. 4096
  705. ],
  706. [
  707. 3072,
  708. 3072
  709. ]
  710. ]
  711. ]
  712. },
  713. "properties": {
  714. "_count": 3,
  715. "max_price.value": 1750.0,
  716. "min_price.value": 0.0,
  717. "avg_price.value": 1133.3333333333333
  718. },
  719. "type": 3
  720. }
  721. ]
  722. },
  723. "meta": {
  724. "extent": 4096,
  725. "version": 2,
  726. "features": [
  727. {
  728. "geometry": {
  729. "type": "Polygon",
  730. "coordinates": [
  731. [
  732. [
  733. 0,
  734. 0
  735. ],
  736. [
  737. 4096,
  738. 0
  739. ],
  740. [
  741. 4096,
  742. 4096
  743. ],
  744. [
  745. 0,
  746. 4096
  747. ],
  748. [
  749. 0,
  750. 0
  751. ]
  752. ]
  753. ]
  754. },
  755. "properties": {
  756. "_shards.failed": 0,
  757. "_shards.skipped": 0,
  758. "_shards.successful": 1,
  759. "_shards.total": 1,
  760. "aggregations._count.avg": 3.0,
  761. "aggregations._count.count": 1,
  762. "aggregations._count.max": 3.0,
  763. "aggregations._count.min": 3.0,
  764. "aggregations._count.sum": 3.0,
  765. "aggregations.avg_price.avg": 1133.3333333333333,
  766. "aggregations.avg_price.count": 1,
  767. "aggregations.avg_price.max": 1133.3333333333333,
  768. "aggregations.avg_price.min": 1133.3333333333333,
  769. "aggregations.avg_price.sum": 1133.3333333333333,
  770. "aggregations.max_price.avg": 1750.0,
  771. "aggregations.max_price.count": 1,
  772. "aggregations.max_price.max": 1750.0,
  773. "aggregations.max_price.min": 1750.0,
  774. "aggregations.max_price.sum": 1750.0,
  775. "aggregations.min_price.avg": 0.0,
  776. "aggregations.min_price.count": 1,
  777. "aggregations.min_price.max": 0.0,
  778. "aggregations.min_price.min": 0.0,
  779. "aggregations.min_price.sum": 0.0,
  780. "hits.max_score": 0.0,
  781. "hits.total.relation": "eq",
  782. "hits.total.value": 3,
  783. "timed_out": false,
  784. "took": 2
  785. },
  786. "type": 3
  787. }
  788. ]
  789. }
  790. }
  791. ----
  792. // NOTCONSOLE