---
setup:

  - do:
      indices.create:
        index: locations
        body:
          mappings:
            properties:
              location:
                type: geo_point

  - do:
      index:
        index:  locations
        body:
          location: POINT(34.25 -21.76)
          value: 1

  - do:
      indices.refresh: {}
---
"no body":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0

---
"size param":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
         size: 0
---
"extent param":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          extent: 256

---
"buffer param":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          buffer: 10

---
"exact bounds":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          exact_bounds: true

---
"with labels":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          with_labels: true

---
"grid precision":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          grid_precision: 3

---
"grid type point":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          grid_type: point

---
"grid agg geotile":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          grid_agg: geotile

---
"grid agg geohex":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          grid_agg: geohex

---
"grid type grid":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          grid_type: grid

---
"grid type centroid":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          grid_type: centroid

---
"grid agg geotile with labels":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          grid_agg: geotile
          with_labels: true

---
"grid agg geohex with labels":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          grid_agg: geohex
          with_labels: true

---
"field field":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          fields: [value]

---
"runtime_fields field":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          runtime_mappings:
            lon:
              script: emit(doc['location'].lon)
              type: double
          fields: [lon]

---
"runtime_fields label position":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          runtime_mappings:
            label_position_lat:
              script:
                GeoPoint point = doc['location'].getLabelPosition();
                emit(point.getLat());
              type: double
            label_position_lon:
              script:
                GeoPoint point = doc['location'].getLabelPosition();
                emit(point.getLon());
              type: double
          fields: [label_position_lat, label_position_lon]

---
"query field":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          query:
            term:
              value: 1

---
"aggs field":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          aggs:
            min_value:
              min:
                field: value

---
"sort field":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          sort: []

---
"track_total_hits as integer":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          track_total_hits: 10

---
"track_total_hits as boolean":
  - do:
      search_mvt:
        index: locations
        field: location
        x: 0
        y: 0
        zoom: 0
        body:
          track_total_hits: true
