Skip to content

Commit a42ff88

Browse files
committed
[API] Updates source docs, adds search_mvt
1 parent bb193dc commit a42ff88

File tree

5 files changed

+144
-3
lines changed

5 files changed

+144
-3
lines changed

elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Actions
2424
# @option arguments [Boolean] :include_yes_decisions Return 'YES' decisions in explanation (default: false)
2525
# @option arguments [Boolean] :include_disk_info Return information about disk usage and shard sizes (default: false)
2626
# @option arguments [Hash] :headers Custom HTTP headers
27-
# @option arguments [Hash] :body The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard'
27+
# @option arguments [Hash] :body The index, shard, and primary flag to explain. Empty means 'explain a randomly-chosen unassigned shard'
2828
#
2929
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.x/cluster-allocation-explain.html
3030
#

elasticsearch-api/lib/elasticsearch/api/actions/indices/field_usage_stats.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module Actions
3232
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
3333
# @option arguments [Hash] :headers Custom HTTP headers
3434
#
35-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.15/field-usage-stats.html
35+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.x/field-usage-stats.html
3636
#
3737
def field_usage_stats(arguments = {})
3838
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]

elasticsearch-api/lib/elasticsearch/api/actions/nodes/stats.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module Actions
2323
#
2424
# @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
2525
# @option arguments [List] :metric Limit the information returned to the specified metrics (options: _all, breaker, fs, http, indices, jvm, os, process, thread_pool, transport, discovery, indexing_pressure)
26-
# @option arguments [List] :index_metric Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. (options: _all, completion, docs, fielddata, query_cache, flush, get, indexing, merge, request_cache, refresh, search, segments, store, warmer, suggest)
26+
# @option arguments [List] :index_metric Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. (options: _all, completion, docs, fielddata, query_cache, flush, get, indexing, merge, request_cache, refresh, search, segments, store, warmer, suggest, shards)
2727
# @option arguments [List] :completion_fields A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards)
2828
# @option arguments [List] :fielddata_fields A comma-separated list of fields for `fielddata` index metric (supports wildcards)
2929
# @option arguments [List] :fields A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards)
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
module Elasticsearch
19+
module API
20+
module Actions
21+
# Searches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile.
22+
# This functionality is Experimental and may be changed or removed
23+
# completely in a future release. Elastic will take a best effort approach
24+
# to fix any issues, but experimental features are not subject to the
25+
# support SLA of official GA features.
26+
#
27+
# @option arguments [List] :index Comma-separated list of data streams, indices, or aliases to search
28+
# @option arguments [String] :field Field containing geospatial data to return
29+
# @option arguments [Integer] :zoom Zoom level for the vector tile to search
30+
# @option arguments [Integer] :x X coordinate for the vector tile to search
31+
# @option arguments [Integer] :y Y coordinate for the vector tile to search
32+
# @option arguments [Boolean] :exact_bounds If false, the meta layer's feature is the bounding box of the tile. If true, the meta layer's feature is a bounding box resulting from a `geo_bounds` aggregation.
33+
# @option arguments [Number] :extent Size, in pixels, of a side of the vector tile.
34+
# @option arguments [Number] :grid_precision Additional zoom levels available through the aggs layer. Accepts 0-8.
35+
# @option arguments [String] :grid_type Determines the geometry type for features in the aggs layer. (options: grid, point)
36+
# @option arguments [Number] :size Maximum number of features to return in the hits layer. Accepts 0-10000.
37+
# @option arguments [Hash] :headers Custom HTTP headers
38+
# @option arguments [Hash] :body Search request body.
39+
#
40+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-vector-tile-api.html
41+
#
42+
def search_mvt(arguments = {})
43+
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
44+
raise ArgumentError, "Required argument 'field' missing" unless arguments[:field]
45+
raise ArgumentError, "Required argument 'zoom' missing" unless arguments[:zoom]
46+
raise ArgumentError, "Required argument 'x' missing" unless arguments[:x]
47+
raise ArgumentError, "Required argument 'y' missing" unless arguments[:y]
48+
49+
headers = arguments.delete(:headers) || {}
50+
51+
arguments = arguments.clone
52+
53+
_index = arguments.delete(:index)
54+
55+
_field = arguments.delete(:field)
56+
57+
_zoom = arguments.delete(:zoom)
58+
59+
_x = arguments.delete(:x)
60+
61+
_y = arguments.delete(:y)
62+
63+
method = if arguments[:body]
64+
Elasticsearch::API::HTTP_POST
65+
else
66+
Elasticsearch::API::HTTP_GET
67+
end
68+
69+
path = "#{Utils.__listify(_index)}/_mvt/#{Utils.__listify(_field)}/#{Utils.__listify(_zoom)}/#{Utils.__listify(_x)}/#{Utils.__listify(_y)}"
70+
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
71+
72+
body = arguments[:body]
73+
perform_request(method, path, params, body, headers).body
74+
end
75+
76+
# Register this action with its valid params when the module is loaded.
77+
#
78+
# @since 6.2.0
79+
ParamsRegistry.register(:search_mvt, [
80+
:exact_bounds,
81+
:extent,
82+
:grid_precision,
83+
:grid_type,
84+
:size
85+
].freeze)
86+
end
87+
end
88+
end
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'spec_helper'
19+
20+
describe 'client#search_mvt' do
21+
let(:expected_args) do
22+
[
23+
method,
24+
url,
25+
params,
26+
body,
27+
{}
28+
]
29+
end
30+
31+
context 'with right parameters' do
32+
let(:method) { 'GET' }
33+
let(:url) { 'foo/_mvt/field/10/57.2127/6.2348' }
34+
let(:params) { {} }
35+
let(:body) { nil }
36+
37+
it 'performs the request' do
38+
expect(client_double.search_mvt(index: 'foo', field: 'field', zoom: 10, x: 57.2127, y: 6.2348)).to eq({})
39+
end
40+
end
41+
42+
context 'when a param is missing' do
43+
let(:client) do
44+
Class.new { include Elasticsearch::API }.new
45+
end
46+
47+
it 'raises an ArgumentError' do
48+
expect{
49+
client.search_mvt
50+
}.to raise_exception(ArgumentError)
51+
end
52+
end
53+
end

0 commit comments

Comments
 (0)