diff --git a/go.mod b/go.mod index 7775e461fc934933a10529bdbf5a099365c3b183..9d01824361ee84f1a3f4fb83a935c46b6726a166 100644 --- a/go.mod +++ b/go.mod @@ -4,4 +4,4 @@ go 1.11 // go: no requirements found in vendor/vendor.json -require github.com/olivere/elastic/v7 v7.0.26 +require github.com/olivere/elastic/v7 v7.0.32 diff --git a/go.sum b/go.sum index 62640e69502c8999127d80b0e676ede6cd80b1fd..d000e4e7b5d9c19b41fa5e8a560c6247a45aa5ad 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,7 @@ github.com/aws/aws-sdk-go v1.33.5/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU github.com/aws/aws-sdk-go v1.35.20/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k= github.com/aws/aws-sdk-go v1.38.3/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.38.17/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= +github.com/aws/aws-sdk-go v1.43.21/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= @@ -14,10 +15,13 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -39,6 +43,7 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -63,6 +68,8 @@ github.com/olivere/elastic/v7 v7.0.25 h1:q3ef8PqC4PyT3b8BAcjDVo48KNzr0HVKosMqMsF github.com/olivere/elastic/v7 v7.0.25/go.mod h1:ySKeM+7yrE9HmsUi6+vSp0anvWiDOuPa9kpuknxjKbU= github.com/olivere/elastic/v7 v7.0.26 h1:KjLLCCpHb0ap+kA2s16c+Czs7kxBOk6DmPoy8D9ZozA= github.com/olivere/elastic/v7 v7.0.26/go.mod h1:ySKeM+7yrE9HmsUi6+vSp0anvWiDOuPa9kpuknxjKbU= +github.com/olivere/elastic/v7 v7.0.32 h1:R7CXvbu8Eq+WlsLgxmKVKPox0oOwAE/2T9Si5BnvK6E= +github.com/olivere/elastic/v7 v7.0.32/go.mod h1:c7PVmLe3Fxq77PIfY/bZmxY/TAamBhCzZ8xDOE09a9k= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -77,9 +84,12 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/otel v1.5.0/go.mod h1:Jm/m+rNp/z0eqJc74H7LPwQ3G87qkU/AnnAydAjSAHk= +go.opentelemetry.io/otel/trace v1.5.0/go.mod h1:sq55kfhjXYr1zVSyexg0w1mpa03AYXR5eyTkB9NPPdE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -94,6 +104,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -104,9 +115,13 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= diff --git a/vendor/github.com/olivere/elastic/v7/.gitignore b/vendor/github.com/olivere/elastic/v7/.gitignore index caa3019c887268ef44d19e9675dc900b82b40e09..d862e893b521b60cb162eba0923024a3d1331f3e 100644 --- a/vendor/github.com/olivere/elastic/v7/.gitignore +++ b/vendor/github.com/olivere/elastic/v7/.gitignore @@ -25,6 +25,7 @@ _testmain.go /.vscode/ /.idea/ +/data /debug.test /generator /cluster-test/cluster-test @@ -35,4 +36,3 @@ _testmain.go /spec /tmp /CHANGELOG-3.0.html - diff --git a/vendor/github.com/olivere/elastic/v7/CONTRIBUTORS b/vendor/github.com/olivere/elastic/v7/CONTRIBUTORS index b3d265c1debe11f9fcfe1ba6413ad3ed1389bc72..ef5f932e346b2c6be0bbf5f4b041bc99ee83046b 100644 --- a/vendor/github.com/olivere/elastic/v7/CONTRIBUTORS +++ b/vendor/github.com/olivere/elastic/v7/CONTRIBUTORS @@ -152,9 +152,10 @@ Muhammet Çakır [@cakirmuha](https://github.com/cakirmuha) Munkyu Im [@munkyu](https://github.com/munkyu) naimulhaider [@naimulhaider](https://github.com/naimulhaider) Naoya Yoshizawa [@azihsoyn](https://github.com/azihsoyn) -navins [@ishare](https://github.com/ishare) Naoya Tsutsumi [@tutuming](https://github.com/tutuming) +Nathan Macnamara [@nathanmac](https://github.com/nathanmac) Nathan Lacey [@nlacey](https://github.com/nlacey) +navins [@ishare](https://github.com/ishare) NeoCN [@NeoCN](https://github.com/NeoCN) Nguyen Xuan Dung [@dungnx](https://github.com/dungnx) Nicholas Wolff [@nwolff](https://github.com/nwolff) @@ -163,6 +164,7 @@ Nick Whyte [@nickw444](https://github.com/nickw444) Nicolae Vartolomei [@nvartolomei](https://github.com/nvartolomei) okhowang [@okhowang](https://github.com/okhowang) Orne Brocaar [@brocaar](https://github.com/brocaar) +ottramst [@ottramst](https://github.com/ottramst) Paul [@eyeamera](https://github.com/eyeamera) Paul Oldenburg [@lr-paul](https://github.com/lr-paul) Pedro [@otherview](https://github.com/otherview) diff --git a/vendor/github.com/olivere/elastic/v7/README.md b/vendor/github.com/olivere/elastic/v7/README.md index ee547761b64107254d9eb0c335d05f9f640a1b48..ca0c3be97e443d547625e955b33f857db0aa02b8 100644 --- a/vendor/github.com/olivere/elastic/v7/README.md +++ b/vendor/github.com/olivere/elastic/v7/README.md @@ -295,10 +295,10 @@ Here are a few tips on how to get used to Elastic: - [X] cat aliases - [X] cat allocation - [X] cat count -- [ ] cat fielddata +- [X] cat fielddata - [X] cat health - [X] cat indices -- [ ] cat master +- [x] cat master - [ ] cat nodeattrs - [ ] cat nodes - [ ] cat pending tasks @@ -308,7 +308,7 @@ Here are a few tips on how to get used to Elastic: - [ ] cat thread pool - [ ] cat shards - [ ] cat segments -- [ ] cat snapshots +- [X] cat snapshots - [ ] cat templates ### Cluster APIs @@ -327,6 +327,13 @@ Here are a few tips on how to get used to Elastic: - [ ] Nodes hot_threads - [ ] Cluster Allocation Explain API +### Rollup APIs (XPack) +- [x] Create Job +- [x] Delete Job +- [x] Get Job +- [x] Start Job +- [x] Stop Job + ### Query DSL - [x] Match All Query @@ -340,6 +347,8 @@ Here are a few tips on how to get used to Elastic: - [x] Common Terms Query - [x] Query String Query - [x] Simple Query String Query + - [x] Combined Fields Query + - [x] Intervals Query - Term level queries - [x] Term Query - [x] Terms Query diff --git a/vendor/github.com/olivere/elastic/v7/cat_master.go b/vendor/github.com/olivere/elastic/v7/cat_master.go new file mode 100644 index 0000000000000000000000000000000000000000..112169075dba04e00c2f761af6d2c19cfb9d1e04 --- /dev/null +++ b/vendor/github.com/olivere/elastic/v7/cat_master.go @@ -0,0 +1,191 @@ +// Copyright 2012-present Oliver Eilhard. All rights reserved. +// Use of this source code is governed by a MIT-license. +// See http://olivere.mit-license.org/license.txt for details. + +package elastic + +import ( + "context" + "fmt" + "net/http" + "net/url" + "strings" +) + +// CatMasterService shows information about the master node, +// including the ID, bound IP address, and name. +// +// See https://www.elastic.co/guide/en/elasticsearch/reference/7.12/cat-master.html +// for details. +type CatMasterService struct { + client *Client + + pretty *bool // pretty format the returned JSON response + human *bool // return human readable values for statistics + errorTrace *bool // include the stack trace of returned errors + filterPath []string // list of filters used to reduce the response + headers http.Header // custom request-level HTTP headers + + local *bool + masterTimeout string + columns []string + sort []string // list of columns for sort order +} + +// NewCatMasterService creates a new CatMasterService +func NewCatMasterService(client *Client) *CatMasterService { + return &CatMasterService{ + client: client, + } +} + +// Pretty tells Elasticsearch whether to return a formatted JSON response. +func (s *CatMasterService) Pretty(pretty bool) *CatMasterService { + s.pretty = &pretty + return s +} + +// Human specifies whether human readable values should be returned in +// the JSON response, e.g. "7.5mb". +func (s *CatMasterService) Human(human bool) *CatMasterService { + s.human = &human + return s +} + +// ErrorTrace specifies whether to include the stack trace of returned errors. +func (s *CatMasterService) ErrorTrace(errorTrace bool) *CatMasterService { + s.errorTrace = &errorTrace + return s +} + +// FilterPath specifies a list of filters used to reduce the response. +func (s *CatMasterService) FilterPath(filterPath ...string) *CatMasterService { + s.filterPath = filterPath + return s +} + +// Header adds a header to the request. +func (s *CatMasterService) Header(name string, value string) *CatMasterService { + if s.headers == nil { + s.headers = http.Header{} + } + s.headers.Add(name, value) + return s +} + +// Headers specifies the headers of the request. +func (s *CatMasterService) Headers(headers http.Header) *CatMasterService { + s.headers = headers + return s +} + +// Local indicates to return local information, i.e. do not retrieve +// the state from master node (default: false). +func (s *CatMasterService) Local(local bool) *CatMasterService { + s.local = &local + return s +} + +// MasterTimeout is the explicit operation timeout for connection to master node. +func (s *CatMasterService) MasterTimeout(masterTimeout string) *CatMasterService { + s.masterTimeout = masterTimeout + return s +} + +// Columns to return in the response. +// To get a list of all possible columns to return, run the following command +// in your terminal: +// +// Example: +// curl 'http://localhost:9200/_cat/master?help' +// +// You can use Columns("*") to return all possible columns. That might take +// a little longer than the default set of columns. +func (s *CatMasterService) Columns(columns ...string) *CatMasterService { + s.columns = columns + return s +} + +// Sort is a list of fields to sort by. +func (s *CatMasterService) Sort(fields ...string) *CatMasterService { + s.sort = fields + return s +} + +// buildURL builds the URL for the operation. +func (s *CatMasterService) buildURL() (string, url.Values, error) { + // Build URL + path := "/_cat/master" + + // Add query string parameters + params := url.Values{ + "format": []string{"json"}, // always returns as JSON + } + if v := s.pretty; v != nil { + params.Set("pretty", fmt.Sprint(*v)) + } + if v := s.human; v != nil { + params.Set("human", fmt.Sprint(*v)) + } + if v := s.errorTrace; v != nil { + params.Set("error_trace", fmt.Sprint(*v)) + } + if len(s.filterPath) > 0 { + params.Set("filter_path", strings.Join(s.filterPath, ",")) + } + if v := s.local; v != nil { + params.Set("local", fmt.Sprint(*v)) + } + if s.masterTimeout != "" { + params.Set("master_timeout", s.masterTimeout) + } + if len(s.sort) > 0 { + params.Set("s", strings.Join(s.sort, ",")) + } + if len(s.columns) > 0 { + params.Set("h", strings.Join(s.columns, ",")) + } + return path, params, nil +} + +// Do executes the operation. +func (s *CatMasterService) Do(ctx context.Context) (CatMasterResponse, error) { + // Get URL for request + path, params, err := s.buildURL() + if err != nil { + return nil, err + } + + // Get HTTP response + res, err := s.client.PerformRequest(ctx, PerformRequestOptions{ + Method: "GET", + Path: path, + Params: params, + Headers: s.headers, + }) + if err != nil { + return nil, err + } + + // Return operation response + var ret CatMasterResponse + if err := s.client.decoder.Decode(res.Body, &ret); err != nil { + return nil, err + } + return ret, nil +} + +// -- Result of a get request. + +// CatMasterResponse is the outcome of CatMasterService.Do. +type CatMasterResponse []CatMasterResponseRow + +// CatMasterResponseRow is a single row in a CatMasterResponse. +// Notice that not all of these fields might be filled; that depends +// on the number of columns chose in the request (see CatMasterService.Columns). +type CatMasterResponseRow struct { + ID string `json:"id"` + Host string `json:"host"` + IP string `json:"ip"` + Node string `json:"node"` +} diff --git a/vendor/github.com/olivere/elastic/v7/cat_snapshots.go b/vendor/github.com/olivere/elastic/v7/cat_snapshots.go new file mode 100644 index 0000000000000000000000000000000000000000..67a8b57cced1d0864234643202224c8ec242685a --- /dev/null +++ b/vendor/github.com/olivere/elastic/v7/cat_snapshots.go @@ -0,0 +1,250 @@ +// Copyright 2012-present Oliver Eilhard. All rights reserved. +// Use of this source code is governed by a MIT-license. +// See http://olivere.mit-license.org/license.txt for details. + +package elastic + +import ( + "context" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/olivere/elastic/v7/uritemplates" +) + +// CatSnapshotsService returns the list of snapshots. +// +// See https://www.elastic.co/guide/en/elasticsearch/reference/7.13/cat-snapshots.html +// for details. +type CatSnapshotsService struct { + client *Client + + pretty *bool // pretty format the returned JSON response + human *bool // return human readable values for statistics + errorTrace *bool // include the stack trace of returned errors + filterPath []string // list of filters used to reduce the response + headers http.Header // custom request-level HTTP headers + + repository string // snapshot repository used to limit the request + masterTimeout string + columns []string + sort []string // list of columns for sort order +} + +// NewCatSnapshotsService creates a new NewCatSnapshotsService. +func NewCatSnapshotsService(client *Client) *CatSnapshotsService { + return &CatSnapshotsService{ + client: client, + } +} + +// Pretty tells Elasticsearch whether to return a formatted JSON response. +func (s *CatSnapshotsService) Pretty(pretty bool) *CatSnapshotsService { + s.pretty = &pretty + return s +} + +// Human specifies whether human readable values should be returned in +// the JSON response, e.g. "7.5mb". +func (s *CatSnapshotsService) Human(human bool) *CatSnapshotsService { + s.human = &human + return s +} + +// ErrorTrace specifies whether to include the stack trace of returned errors. +func (s *CatSnapshotsService) ErrorTrace(errorTrace bool) *CatSnapshotsService { + s.errorTrace = &errorTrace + return s +} + +// FilterPath specifies a list of filters used to reduce the response. +func (s *CatSnapshotsService) FilterPath(filterPath ...string) *CatSnapshotsService { + s.filterPath = filterPath + return s +} + +// Header adds a header to the request. +func (s *CatSnapshotsService) Header(name string, value string) *CatSnapshotsService { + if s.headers == nil { + s.headers = http.Header{} + } + s.headers.Add(name, value) + return s +} + +// Headers specifies the headers of the request. +func (s *CatSnapshotsService) Headers(headers http.Header) *CatSnapshotsService { + s.headers = headers + return s +} + +// Repository specifies the napshot repository used to limit the request. +func (s *CatSnapshotsService) Repository(repository string) *CatSnapshotsService { + s.repository = repository + return s +} + +// MasterTimeout is the explicit operation timeout for connection to master node. +func (s *CatSnapshotsService) MasterTimeout(masterTimeout string) *CatSnapshotsService { + s.masterTimeout = masterTimeout + return s +} + +// Columns to return in the response. +// To get a list of all possible columns to return, run the following command +// in your terminal: +// +// Example: +// curl 'http://localhost:9200/_cat/snapshots/<repository>?help' +// +// You can use Columns("*") to return all possible columns. That might take +// a little longer than the default set of columns. +func (s *CatSnapshotsService) Columns(columns ...string) *CatSnapshotsService { + s.columns = columns + return s +} + +// Sort is a list of fields to sort by. +func (s *CatSnapshotsService) Sort(fields ...string) *CatSnapshotsService { + s.sort = fields + return s +} + +// buildURL builds the URL for the operation. +func (s *CatSnapshotsService) buildURL() (string, url.Values, error) { + // Build URL + var ( + path string + err error + ) + + if s.repository != "" { + path, err = uritemplates.Expand("/_cat/snapshots/{repository}", map[string]string{ + "repository": s.repository, + }) + } else { + path = "/_cat/snapshots" + } + if err != nil { + return "", url.Values{}, err + } + + // Add query string parameters + params := url.Values{ + "format": []string{"json"}, // always returns as JSON + } + if v := s.pretty; v != nil { + params.Set("pretty", fmt.Sprint(*v)) + } + if v := s.human; v != nil { + params.Set("human", fmt.Sprint(*v)) + } + if v := s.errorTrace; v != nil { + params.Set("error_trace", fmt.Sprint(*v)) + } + if len(s.filterPath) > 0 { + params.Set("filter_path", strings.Join(s.filterPath, ",")) + } + if s.masterTimeout != "" { + params.Set("master_timeout", s.masterTimeout) + } + // TODO + if len(s.columns) > 0 { + // loop through all columns and apply alias if needed + for i, column := range s.columns { + if fullValueRaw, isAliased := catSnapshotsResponseRowAliasesMap[column]; isAliased { + // alias can be translated to multiple fields, + // so if translated value contains a comma, than replace the first value + // and append the others + if strings.Contains(fullValueRaw, ",") { + fullValues := strings.Split(fullValueRaw, ",") + s.columns[i] = fullValues[0] + s.columns = append(s.columns, fullValues[1:]...) + } else { + s.columns[i] = fullValueRaw + } + } + } + + params.Set("h", strings.Join(s.columns, ",")) + } + if len(s.sort) > 0 { + params.Set("s", strings.Join(s.sort, ",")) + } + return path, params, nil +} + +// Do executes the operation. +func (s *CatSnapshotsService) Do(ctx context.Context) (CatSnapshotsResponse, error) { + // Get URL for request + path, params, err := s.buildURL() + if err != nil { + return nil, err + } + + // Get HTTP response + res, err := s.client.PerformRequest(ctx, PerformRequestOptions{ + Method: "GET", + Path: path, + Params: params, + Headers: s.headers, + }) + if err != nil { + return nil, err + } + + // Return operation response + var ret CatSnapshotsResponse + if err := s.client.decoder.Decode(res.Body, &ret); err != nil { + return nil, err + } + return ret, nil +} + +// -- Result of a get request. + +// CatSnapshotsResponse is the outcome of CatSnapshotsService.Do. +type CatSnapshotsResponse []CatSnapshotsResponseRow + +// CatSnapshotssResponseRow specifies the data returned for one index +// of a CatSnapshotsResponse. Notice that not all of these fields might +// be filled; that depends on the number of columns chose in the +// request (see CatSnapshotsService.Columns). +type CatSnapshotsResponseRow struct { + ID string `json:"id"` // ID of the snapshot, such as "snap1". + Repository string `json:"repository"` // Name of the repository, such as "repo1". + Status string `json:"status"` // One of "FAILED", "INCOMPATIBLE", "IN_PROGRESS", "PARTIAL" or "SUCCESS". + StartEpoch string `json:"start_epoch"` // Unix epoch time at which the snapshot process started. + StartTime string `json:"start_time"` // HH:MM:SS time at which the snapshot process started. + EndEpoch string `json:"end_epoch"` // Unix epoch time at which the snapshot process ended. + EndTime string `json:"end_time"` // HH:MM:SS time at which the snapshot process ended. + Duration string `json:"duration"` // Time it took the snapshot process to complete in time units. + Indices string `json:"indices"` // Number of indices in the snapshot. + SuccessfulShards string `json:"successful_shards"` // Number of successful shards in the snapshot. + FailedShards string `json:"failed_shards"` // Number of failed shards in the snapshot. + TotalShards string `json:"total_shards"` // Total number of shards in the snapshot. + Reason string `json:"reason"` // Reason for any snapshot failures. +} + +// catSnapshotsResponseRowAliasesMap holds the global map for columns aliases +// the map is used by CatSnapshotsService.buildURL. +// For backwards compatibility some fields are able to have the same aliases +// that means that one alias can be translated to different columns (from different elastic versions) +// example for understanding: rto -> RefreshTotal, RefreshExternalTotal +var catSnapshotsResponseRowAliasesMap = map[string]string{ + "snapshot": "id", + "re": "repository", + "s": "status", + "ste": "start_epoch", + "sti": "start_time", + "ete": "end_epoch", + "eti": "end_time", + "dur": "duration", + "i": "indices", + "ss": "successful_shards", + "fs": "failed_shards", + "ts": "total_shards", + "`r": "reason", +} diff --git a/vendor/github.com/olivere/elastic/v7/client.go b/vendor/github.com/olivere/elastic/v7/client.go index d83906c2938acc1e673d4a6a5105ddc0cf93acfe..3ebb5e8650d706726c98e9b3c78bc97a0f0847e7 100644 --- a/vendor/github.com/olivere/elastic/v7/client.go +++ b/vendor/github.com/olivere/elastic/v7/client.go @@ -26,7 +26,7 @@ import ( const ( // Version is the current version of Elastic. - Version = "7.0.26" + Version = "7.0.32" // DefaultURL is the default endpoint of Elasticsearch on the local machine. // It is used e.g. when initializing a new Client without a specific URL. @@ -84,6 +84,9 @@ const ( ) var ( + // nilByte is used in JSON marshal/unmarshal + nilByte = []byte("null") + // ErrNoClient is raised when no Elasticsearch node is available. ErrNoClient = errors.New("no Elasticsearch node available") @@ -1499,7 +1502,7 @@ func (c *Client) PerformRequest(ctx context.Context, opt PerformRequestOptions) duration := time.Now().UTC().Sub(start) c.infof("%s %s [status:%d, request:%.3fs]", strings.ToUpper(opt.Method), - req.URL, + req.URL.Redacted(), resp.StatusCode, float64(int64(duration/time.Millisecond))/1000) @@ -1691,11 +1694,17 @@ func (c *Client) CloseIndex(name string) *IndicesCloseService { } // FreezeIndex freezes an index. +// +// Deprecated: Frozen indices are deprecated because they provide no benefit +// given improvements in heap memory utilization. func (c *Client) FreezeIndex(name string) *IndicesFreezeService { return NewIndicesFreezeService(c).Index(name) } // UnfreezeIndex unfreezes an index. +// +// Deprecated: Frozen indices are deprecated because they provide no benefit +// given improvements in heap memory utilization. func (c *Client) UnfreezeIndex(name string) *IndicesUnfreezeService { return NewIndicesUnfreezeService(c).Index(name) } @@ -1776,6 +1785,8 @@ func (c *Client) Aliases() *AliasesService { // in https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-templates-v1.html. // // See e.g. IndexPutIndexTemplate and IndexPutComponentTemplate for the new version(s). +// +// Deprecated: Legacy index templates are deprecated in favor of composable templates. func (c *Client) IndexGetTemplate(names ...string) *IndicesGetTemplateService { return NewIndicesGetTemplateService(c).Name(names...) } @@ -1786,6 +1797,8 @@ func (c *Client) IndexGetTemplate(names ...string) *IndicesGetTemplateService { // in https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-templates-v1.html. // // See e.g. IndexPutIndexTemplate and IndexPutComponentTemplate for the new version(s). +// +// Deprecated: Legacy index templates are deprecated in favor of composable templates. func (c *Client) IndexTemplateExists(name string) *IndicesExistsTemplateService { return NewIndicesExistsTemplateService(c).Name(name) } @@ -1796,6 +1809,8 @@ func (c *Client) IndexTemplateExists(name string) *IndicesExistsTemplateService // in https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-templates-v1.html. // // See e.g. IndexPutIndexTemplate and IndexPutComponentTemplate for the new version(s). +// +// Deprecated: Legacy index templates are deprecated in favor of composable templates. func (c *Client) IndexPutTemplate(name string) *IndicesPutTemplateService { return NewIndicesPutTemplateService(c).Name(name) } @@ -1806,6 +1821,8 @@ func (c *Client) IndexPutTemplate(name string) *IndicesPutTemplateService { // in https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-templates-v1.html. // // See e.g. IndexPutIndexTemplate and IndexPutComponentTemplate for the new version(s). +// +// Deprecated: Legacy index templates are deprecated in favor of composable templates. func (c *Client) IndexDeleteTemplate(name string) *IndicesDeleteTemplateService { return NewIndicesDeleteTemplateService(c).Name(name) } @@ -1885,7 +1902,6 @@ func (c *Client) GetFieldMapping() *IndicesGetFieldMappingService { // -- cat APIs -- -// TODO cat master // TODO cat nodes // TODO cat pending tasks // TODO cat plugins @@ -1894,6 +1910,11 @@ func (c *Client) GetFieldMapping() *IndicesGetFieldMappingService { // TODO cat shards // TODO cat segments +// CatMaster returns information about the master node +func (c *Client) CatMaster() *CatMasterService { + return NewCatMasterService(c) +} + // CatFielddata returns information about the amount of heap memory currently used by the field data cache. func (c *Client) CatFielddata() *CatFielddataService { return NewCatFielddataService(c) @@ -1929,6 +1950,11 @@ func (c *Client) CatShards() *CatShardsService { return NewCatShardsService(c) } +// CatSnapshots returns information about snapshots. +func (c *Client) CatSnapshots() *CatSnapshotsService { + return NewCatSnapshotsService(c) +} + // -- Ingest APIs -- // IngestPutPipeline adds pipelines and updates existing pipelines in @@ -2179,6 +2205,33 @@ func (c *Client) XPackSecurityDeleteUser(username string) *XPackSecurityDeleteUs return NewXPackSecurityDeleteUserService(c).Username(username) } +// -- X-Pack Rollup -- + +// XPackRollupPut creates or updates a rollup job. +func (c *Client) XPackRollupPut(jobId string) *XPackRollupPutService { + return NewXPackRollupPutService(c).JobId(jobId) +} + +// XPackRollupGet gets a rollup job. +func (c *Client) XPackRollupGet(jobId string) *XPackRollupGetService { + return NewXPackRollupGetService(c).JobId(jobId) +} + +// XPackRollupDelete deletes a rollup job. +func (c *Client) XPackRollupDelete(jobId string) *XPackRollupDeleteService { + return NewXPackRollupDeleteService(c).JobId(jobId) +} + +// XPackRollupStart starts a rollup job. +func (c *Client) XPackRollupStart(jobId string) *XPackRollupStartService { + return NewXPackRollupStartService(c).JobId(jobId) +} + +// XPackRollupStop stops a rollup job. +func (c *Client) XPackRollupStop(jobId string) *XPackRollupStopService { + return NewXPackRollupStopService(c).JobId(jobId) +} + // -- X-Pack Watcher -- // XPackWatchPut adds a watch. diff --git a/vendor/github.com/olivere/elastic/v7/cluster_state.go b/vendor/github.com/olivere/elastic/v7/cluster_state.go index aecd623d03b1db512bc560e57b1462cd0ebbbcd5..33ebf35ede5b18a46b80f3a844f7ccf8e00713a4 100644 --- a/vendor/github.com/olivere/elastic/v7/cluster_state.go +++ b/vendor/github.com/olivere/elastic/v7/cluster_state.go @@ -235,17 +235,19 @@ func (s *ClusterStateService) Do(ctx context.Context) (*ClusterStateResponse, er // ClusterStateResponse is the response of ClusterStateService.Do. type ClusterStateResponse struct { - ClusterName string `json:"cluster_name"` - ClusterUUID string `json:"cluster_uuid"` - Version int64 `json:"version"` - StateUUID string `json:"state_uuid"` - MasterNode string `json:"master_node"` - Blocks map[string]*clusterBlocks `json:"blocks"` - Nodes map[string]*discoveryNode `json:"nodes"` - Metadata *clusterStateMetadata `json:"metadata"` - RoutingTable *clusterStateRoutingTable `json:"routing_table"` - RoutingNodes *clusterStateRoutingNode `json:"routing_nodes"` - Customs map[string]interface{} `json:"customs"` + ClusterName string `json:"cluster_name"` + ClusterUUID string `json:"cluster_uuid"` + Version int64 `json:"version"` + StateUUID string `json:"state_uuid"` + MasterNode string `json:"master_node"` + Blocks map[string]*clusterBlocks `json:"blocks"` + Nodes map[string]*discoveryNode `json:"nodes"` + Metadata *clusterStateMetadata `json:"metadata"` + RoutingTable *clusterStateRoutingTable `json:"routing_table"` + RoutingNodes *clusterStateRoutingNode `json:"routing_nodes"` + Snapshots map[string]interface{} `json:"snapshots"` + SnapshotDeletions map[string]interface{} `json:"snapshot_deletions"` + Customs map[string]interface{} `json:"customs"` } type clusterBlocks struct { @@ -273,10 +275,16 @@ type clusterStateMetadata struct { Unassigned []*shardRouting `json:"unassigned"` Nodes []*shardRouting `json:"nodes"` } `json:"routing_nodes"` - Customs map[string]interface{} `json:"customs"` - Ingest map[string]interface{} `json:"ingest"` - StoredScripts map[string]interface{} `json:"stored_scripts"` - IndexGraveyard map[string]interface{} `json:"index-graveyard"` + DataStream map[string]interface{} `json:"data_stream,omitempty"` + Customs map[string]interface{} `json:"customs"` + Ingest map[string]interface{} `json:"ingest"` + StoredScripts map[string]interface{} `json:"stored_scripts"` + IndexGraveyard map[string]interface{} `json:"index-graveyard"` + IndexLifecycle map[string]interface{} `json:"index_lifecycle"` + Repositories map[string]interface{} `json:"repositories"` + IndexTemplate map[string]interface{} `json:"index_template"` + PersistentTasks map[string]interface{} `json:"persistent_tasks"` + ComponentTemplate map[string]interface{} `json:"component_template"` } type clusterCoordinationMetaData struct { @@ -291,6 +299,7 @@ type discoveryNode struct { EphemeralID string `json:"ephemeral_id"` // e.g. "paHSLpn6QyuVy_n-GM1JAQ" TransportAddress string `json:"transport_address"` // e.g. inet[/1.2.3.4:9300] Attributes map[string]interface{} `json:"attributes"` // e.g. { "data": true, "master": true } + Roles []string `json:"roles,omitempty"` // e.g. ["data","data_cold","master",...] } type clusterStateRoutingTable struct { @@ -306,8 +315,10 @@ type clusterStateRoutingNode struct { type indexTemplateMetaData struct { IndexPatterns []string `json:"index_patterns"` // e.g. ["store-*"] Order int `json:"order"` + Version int `json:"version"` Settings map[string]interface{} `json:"settings"` // index settings Mappings map[string]interface{} `json:"mappings"` // type name -> mapping + Aliases map[string]interface{} `json:"aliases"` } type indexMetaData struct { @@ -317,6 +328,15 @@ type indexMetaData struct { Aliases []string `json:"aliases"` // e.g. [ "alias1", "alias2" ] PrimaryTerms map[string]interface{} `json:"primary_terms"` InSyncAllocations map[string]interface{} `json:"in_sync_allocations"` + Version int `json:"version"` + MappingVersion int `json:"mapping_version"` + SettingsVersion int `json:"settings_version"` + AliasesVersion int `json:"aliases_version"` + RoutingNumShards int `json:"routing_num_shards"` + RolloverInfo interface{} `json:"rollover_info,omitempty"` + System interface{} `json:"system,omitempty"` + TimestampRange interface{} `json:"timestamp_range,omitempty"` + ILM map[string]interface{} `json:"ilm,omitempty"` } type indexRoutingTable struct { diff --git a/vendor/github.com/olivere/elastic/v7/cluster_stats.go b/vendor/github.com/olivere/elastic/v7/cluster_stats.go index 7bb39cf651b4c50d8f252cfc6709faaa58d54593..0c06e7ef019463f517cf020b86f8d30d1375e125 100644 --- a/vendor/github.com/olivere/elastic/v7/cluster_stats.go +++ b/vendor/github.com/olivere/elastic/v7/cluster_stats.go @@ -193,6 +193,72 @@ type ClusterStatsIndices struct { QueryCache *ClusterStatsIndicesQueryCache `json:"query_cache"` Completion *ClusterStatsIndicesCompletion `json:"completion"` Segments *IndexStatsSegments `json:"segments"` + Analysis *ClusterStatsAnalysisStats `json:"analysis"` + Mappings *ClusterStatsMappingStats `json:"mappings"` + Versions []*ClusterStatsVersionStats `json:"versions"` +} + +type ClusterStatsAnalysisStats struct { + CharFilterTypes []IndexFeatureStats `json:"char_filter_types,omitempty"` + TokenizerTypes []IndexFeatureStats `json:"tokenizer_types,omitempty"` + FilterTypes []IndexFeatureStats `json:"filter_types,omitempty"` + AnalyzerTypes []IndexFeatureStats `json:"analyzer_types,omitempty"` + BuiltInCharFilters []IndexFeatureStats `json:"built_in_char_filters,omitempty"` + BuiltInTokenizers []IndexFeatureStats `json:"built_in_tokenizers,omitempty"` + BuiltInFilters []IndexFeatureStats `json:"built_in_filters,omitempty"` + BuiltInAnalyzers []IndexFeatureStats `json:"built_in_analyzers,omitempty"` +} + +type ClusterStatsMappingStats struct { + FieldTypes []IndexFeatureStats `json:"field_types"` + RuntimeFieldTypes []RuntimeFieldStats `json:"runtime_field_types"` +} + +type IndexFeatureStats struct { + Name string `json:"name"` + Count int `json:"count"` + IndexCount int `json:"index_count"` + + ScriptCount int `json:"script_count"` +} + +type RuntimeFieldStats struct { + Name string `json:"name"` + Count int `json:"count"` + IndexCount int `json:"index_count"` + ScriptlessCount int `json:"scriptless_count"` + ShadowedCount int `json:"shadowed_count"` + Lang []string `json:"lang"` + + // FieldScriptStats + + LinesMax int64 `json:"lines_max"` + LinesTotal int64 `json:"lines_total"` + CharsMax int64 `json:"chars_max"` + CharsTotal int64 `json:"chars_total"` + SourceMax int64 `json:"source_max"` + SourceTotal int64 `json:"source_total"` + DocMax int64 `json:"doc_max"` + DocTotal int64 `json:"doc_total"` +} + +type FieldScriptStats struct { + LinesMax int64 `json:"lines_max"` + LinesTotal int64 `json:"lines_total"` + CharsMax int64 `json:"chars_max"` + CharsTotal int64 `json:"chars_total"` + SourceMax int64 `json:"source_max"` + SourceTotal int64 `json:"source_total"` + DocMax int64 `json:"doc_max"` + DocTotal int64 `json:"doc_total"` +} + +type ClusterStatsVersionStats struct { + Version string `json:"version"` + IndexCount int `json:"index_count"` + PrimaryShardCount int `json:"primary_shard_count"` + TotalPrimarySize string `json:"total_primary_size,omitempty"` + TotalPrimaryBytes int64 `json:"total_primary_bytes,omitempty"` } type ClusterStatsIndicesShards struct { @@ -226,8 +292,12 @@ type ClusterStatsIndicesDocs struct { } type ClusterStatsIndicesStore struct { - Size string `json:"size"` // e.g. "5.3gb" - SizeInBytes int64 `json:"size_in_bytes"` + Size string `json:"size"` // e.g. "5.3gb" + SizeInBytes int64 `json:"size_in_bytes"` + TotalDataSetSize string `json:"total_data_set_size,omitempty"` + TotalDataSetSizeInBytes int64 `json:"total_data_set_size_in_bytes,omitempty"` + Reserved string `json:"reserved,omitempty"` + ReservedInBytes int64 `json:"reserved_in_bytes,omitempty"` } type ClusterStatsIndicesFieldData struct { @@ -280,14 +350,25 @@ type ClusterStatsNodes struct { NetworkTypes *ClusterStatsNodesNetworkTypes `json:"network_types"` DiscoveryTypes *ClusterStatsNodesDiscoveryTypes `json:"discovery_types"` PackagingTypes *ClusterStatsNodesPackagingTypes `json:"packaging_types"` + + Ingest *ClusterStatsNodesIngest `json:"ingest"` } type ClusterStatsNodesCount struct { - Total int `json:"total"` - Data int `json:"data"` - CoordinatingOnly int `json:"coordinating_only"` - Master int `json:"master"` - Ingest int `json:"ingest"` + Total int `json:"total"` + Data int `json:"data"` + DataCold int `json:"data_cold"` + DataContent int `json:"data_content"` + DataFrozen int `json:"data_frozen"` + DataHot int `json:"data_hot"` + DataWarm int `json:"data_warm"` + CoordinatingOnly int `json:"coordinating_only"` + Master int `json:"master"` + Ingest int `json:"ingest"` + ML int `json:"ml"` + RemoteClusterClient int `json:"remote_cluster_client"` + Transform int `json:"transform"` + VotingOnly int `json:"voting_only"` } type ClusterStatsNodesOsStats struct { @@ -301,7 +382,11 @@ type ClusterStatsNodesOsStats struct { PrettyName string `json:"pretty_name"` Value int `json:"count"` } `json:"pretty_names"` - Mem *ClusterStatsNodesOsStatsMem `json:"mem"` + Mem *ClusterStatsNodesOsStatsMem `json:"mem"` + Architectures []struct { + Arch string `json:"arch"` + Count int `json:"count"` + } `json:"architectures"` // CPU []*ClusterStatsNodesOsStatsCPU `json:"cpu"` } @@ -414,3 +499,8 @@ type ClusterStatsNodesPackagingType struct { Type string `json:"type"` // e.g. "docker" Count int `json:"count"` // e.g. 1 } + +type ClusterStatsNodesIngest struct { + NumberOfPipelines int `json:"number_of_pipelines"` + ProcessorStats map[string]interface{} `json:"processor_stats"` +} diff --git a/vendor/github.com/olivere/elastic/v7/delete_by_query.go b/vendor/github.com/olivere/elastic/v7/delete_by_query.go index 4c98444f4e934cba19ec2a90c85192c44dcce706..d1f690eab4ebae6f54e49349bdd49b7521cb3103 100644 --- a/vendor/github.com/olivere/elastic/v7/delete_by_query.go +++ b/vendor/github.com/olivere/elastic/v7/delete_by_query.go @@ -45,6 +45,7 @@ type DeleteByQueryService struct { ignoreUnavailable *bool lenient *bool lowercaseExpandedTerms *bool + maxDocs *int preference string q string refresh string @@ -191,7 +192,7 @@ func (s *DeleteByQueryService) AbortOnVersionConflict() *DeleteByQueryService { return s } -// ProceedOnVersionConflict aborts the request on version conflicts. +// ProceedOnVersionConflict proceeds the request on version conflicts. // It is an alias to setting Conflicts("proceed"). func (s *DeleteByQueryService) ProceedOnVersionConflict() *DeleteByQueryService { s.conflicts = "proceed" @@ -263,6 +264,13 @@ func (s *DeleteByQueryService) LowercaseExpandedTerms(lowercaseExpandedTerms boo return s } +// MaxDocs specifies the maximum number of documents to process. +// Defaults to all documents. +func (s *DeleteByQueryService) MaxDocs(maxDocs int) *DeleteByQueryService { + s.maxDocs = &maxDocs + return s +} + // Preference specifies the node or shard the operation should be performed on // (default: random). func (s *DeleteByQueryService) Preference(preference string) *DeleteByQueryService { @@ -553,6 +561,9 @@ func (s *DeleteByQueryService) buildURL() (string, url.Values, error) { if s.lowercaseExpandedTerms != nil { params.Set("lowercase_expanded_terms", fmt.Sprintf("%v", *s.lowercaseExpandedTerms)) } + if s.maxDocs != nil { + params.Set("max_docs", fmt.Sprint(*s.maxDocs)) + } if s.preference != "" { params.Set("preference", s.preference) } diff --git a/vendor/github.com/olivere/elastic/v7/docker-compose.cluster.yml b/vendor/github.com/olivere/elastic/v7/docker-compose.cluster.yml index f8a9c8303e5f3a7b335dde8948ce0ddc8f065f92..ac1ab3c59e90b640075eabf2893393fee16e4204 100644 --- a/vendor/github.com/olivere/elastic/v7/docker-compose.cluster.yml +++ b/vendor/github.com/olivere/elastic/v7/docker-compose.cluster.yml @@ -1,8 +1,6 @@ -version: '3' - services: es1: - image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION:-7.13.2} + image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION:-7.14.0} hostname: es1 environment: - bootstrap.memory_lock=true @@ -28,7 +26,7 @@ services: - 9200:9200 es2: - image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION:-7.13.2} + image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION:-7.14.0} hostname: es2 environment: - bootstrap.memory_lock=true @@ -54,7 +52,7 @@ services: - 9201:9200 es3: - image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION:-7.13.2} + image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION:-7.14.0} hostname: es3 environment: - bootstrap.memory_lock=true diff --git a/vendor/github.com/olivere/elastic/v7/docker-compose.yml b/vendor/github.com/olivere/elastic/v7/docker-compose.yml index a3054a66b04a26b17c9ee7cc854fe9c09ec51f16..d4f9bd843146ba6a1fe9504b46ab88397c04dfa5 100644 --- a/vendor/github.com/olivere/elastic/v7/docker-compose.yml +++ b/vendor/github.com/olivere/elastic/v7/docker-compose.yml @@ -1,8 +1,6 @@ -version: '3' - services: elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION:-7.13.2} + image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION:-7.17.1} hostname: elasticsearch environment: - cluster.name=elasticsearch @@ -15,6 +13,7 @@ services: - network.publish_host=127.0.0.1 - logger.org.elasticsearch=warn - xpack.security.enabled=false + - path.repo=/usr/share/elasticsearch/backup - "ES_JAVA_OPTS=-Xms1g -Xmx1g" ulimits: nproc: 65536 @@ -24,12 +23,12 @@ services: memlock: soft: -1 hard: -1 - # volumes: - # - ./data/elasticsearch:/usr/share/elasticsearch/data + volumes: + - ./data/backup:/usr/share/elasticsearch/backup ports: - 9200:9200 platinum: - image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION:-7.13.2} + image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION:-7.17.1} hostname: elasticsearch-platinum environment: - cluster.name=platinum @@ -45,6 +44,7 @@ services: - http.port=9210 - network.publish_host=127.0.0.1 - logger.org.elasticsearch=warn + - path.repo=/usr/share/elasticsearch/backup - "ES_JAVA_OPTS=-Xms1g -Xmx1g" - ELASTIC_PASSWORD=elastic ulimits: @@ -55,7 +55,7 @@ services: memlock: soft: -1 hard: -1 - # volumes: - # - ./data/elasticsearch-platinum:/usr/share/elasticsearch/data + volumes: + - ./data/backup:/usr/share/elasticsearch/backup ports: - 9210:9210 diff --git a/vendor/github.com/olivere/elastic/v7/errors.go b/vendor/github.com/olivere/elastic/v7/errors.go index f3bae9d09eeaafee9b22708f6f5fd4354c84f3d2..8a4ed524e039ed9fbf81de2d1284b64d3982544a 100644 --- a/vendor/github.com/olivere/elastic/v7/errors.go +++ b/vendor/github.com/olivere/elastic/v7/errors.go @@ -225,6 +225,14 @@ type ShardOperationFailedException struct { Primary bool `json:"primary,omitempty"` } +type BroadcastResponse struct { + Shards *ShardsInfo `json:"_shards,omitempty"` + Total int `json:"total"` + Successful int `json:"successful"` + Failed int `json:"failed"` + Failures []*ShardOperationFailedException `json:"failures,omitempty"` +} + // FailedNodeException returns an error on the node level. type FailedNodeException struct { *ErrorDetails diff --git a/vendor/github.com/olivere/elastic/v7/field_caps.go b/vendor/github.com/olivere/elastic/v7/field_caps.go index b84a1f13f0bf9477d10a61ad524cb1d5fba06cc9..4b1aa92d0a3db4710d6f7b1bc510d30ab689e58e 100644 --- a/vendor/github.com/olivere/elastic/v7/field_caps.go +++ b/vendor/github.com/olivere/elastic/v7/field_caps.go @@ -32,6 +32,7 @@ type FieldCapsService struct { expandWildcards string fields []string ignoreUnavailable *bool + includeUnmapped *bool bodyJson interface{} bodyString string } @@ -117,6 +118,12 @@ func (s *FieldCapsService) IgnoreUnavailable(ignoreUnavailable bool) *FieldCapsS return s } +// IncludeUnmapped specifies whether unmapped fields whould be included in the response. +func (s *FieldCapsService) IncludeUnmapped(includeUnmapped bool) *FieldCapsService { + s.includeUnmapped = &includeUnmapped + return s +} + // BodyJson is documented as: Field json objects containing the name and optionally a range to filter out indices result, that have results outside the defined bounds. func (s *FieldCapsService) BodyJson(body interface{}) *FieldCapsService { s.bodyJson = body @@ -160,7 +167,7 @@ func (s *FieldCapsService) buildURL() (string, url.Values, error) { params.Set("filter_path", strings.Join(s.filterPath, ",")) } if s.allowNoIndices != nil { - params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices)) + params.Set("allow_no_indices", fmt.Sprint(*s.allowNoIndices)) } if s.expandWildcards != "" { params.Set("expand_wildcards", s.expandWildcards) @@ -169,7 +176,10 @@ func (s *FieldCapsService) buildURL() (string, url.Values, error) { params.Set("fields", strings.Join(s.fields, ",")) } if s.ignoreUnavailable != nil { - params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable)) + params.Set("ignore_unavailable", fmt.Sprint(*s.ignoreUnavailable)) + } + if s.includeUnmapped != nil { + params.Set("include_unmapped", fmt.Sprint(*s.includeUnmapped)) } return path, params, nil } @@ -231,7 +241,9 @@ func (s *FieldCapsService) Do(ctx context.Context) (*FieldCapsResponse, error) { // FieldCapsRequest can be used to set up the body to be used in the // Field Capabilities API. type FieldCapsRequest struct { - Fields []string `json:"fields"` + Fields []string `json:"fields"` // list of fields to retrieve + IndexFilter Query `json:"index_filter,omitempty"` + RuntimeMappings RuntimeMappings `json:"runtime_mappings,omitempty"` } // -- Response -- @@ -248,10 +260,12 @@ type FieldCapsType map[string]FieldCaps // type -> caps // FieldCaps contains capabilities of an individual field. type FieldCaps struct { - Type string `json:"type"` - Searchable bool `json:"searchable"` - Aggregatable bool `json:"aggregatable"` - Indices []string `json:"indices,omitempty"` - NonSearchableIndices []string `json:"non_searchable_indices,omitempty"` - NonAggregatableIndices []string `json:"non_aggregatable_indices,omitempty"` + Type string `json:"type"` + MetadataField bool `json:"metadata_field"` + Searchable bool `json:"searchable"` + Aggregatable bool `json:"aggregatable"` + Indices []string `json:"indices,omitempty"` + NonSearchableIndices []string `json:"non_searchable_indices,omitempty"` + NonAggregatableIndices []string `json:"non_aggregatable_indices,omitempty"` + Meta map[string]interface{} `json:"meta,omitempty"` } diff --git a/vendor/github.com/olivere/elastic/v7/go.mod b/vendor/github.com/olivere/elastic/v7/go.mod index e82873f4d1d3ec0fe28bd600d475f0240c3f011d..1725213ba924ab3f1f4ed76788fa6be7af140199 100644 --- a/vendor/github.com/olivere/elastic/v7/go.mod +++ b/vendor/github.com/olivere/elastic/v7/go.mod @@ -1,16 +1,26 @@ module github.com/olivere/elastic/v7 -go 1.14 +go 1.17 require ( - github.com/aws/aws-sdk-go v1.38.17 + github.com/aws/aws-sdk-go v1.43.21 github.com/fortytw2/leaktest v1.3.0 - github.com/google/go-cmp v0.5.5 + github.com/google/go-cmp v0.5.7 github.com/mailru/easyjson v0.7.7 github.com/opentracing/opentracing-go v1.2.0 github.com/pkg/errors v0.9.1 - github.com/smartystreets/assertions v1.1.1 // indirect github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9 - github.com/smartystreets/gunit v1.4.2 // indirect go.opencensus.io v0.23.0 + go.opentelemetry.io/otel v1.5.0 +) + +require ( + github.com/go-logr/logr v1.2.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/smartystreets/assertions v1.1.1 // indirect + github.com/smartystreets/gunit v1.4.2 // indirect + go.opentelemetry.io/otel/trace v1.5.0 // indirect ) diff --git a/vendor/github.com/olivere/elastic/v7/highlight.go b/vendor/github.com/olivere/elastic/v7/highlight.go index 49e1b4d329061bf21ca21e18b97d98eacf867162..ce2f155ae569e7b8009b57e2ff0f5b86ee5fda77 100644 --- a/vendor/github.com/olivere/elastic/v7/highlight.go +++ b/vendor/github.com/olivere/elastic/v7/highlight.go @@ -18,6 +18,7 @@ type Highlight struct { order *string encoder *string requireFieldMatch *bool + maxAnalyzedOffset *int boundaryMaxScan *int boundaryChars *string boundaryScannerType *string @@ -95,6 +96,11 @@ func (hl *Highlight) RequireFieldMatch(requireFieldMatch bool) *Highlight { return hl } +func (hl *Highlight) MaxAnalyzedOffset(maxAnalyzedOffset int) *Highlight { + hl.maxAnalyzedOffset = &maxAnalyzedOffset + return hl +} + func (hl *Highlight) BoundaryMaxScan(boundaryMaxScan int) *Highlight { hl.boundaryMaxScan = &boundaryMaxScan return hl @@ -184,6 +190,9 @@ func (hl *Highlight) Source() (interface{}, error) { if hl.requireFieldMatch != nil { source["require_field_match"] = *hl.requireFieldMatch } + if hl.maxAnalyzedOffset != nil { + source["max_analyzed_offset"] = *hl.maxAnalyzedOffset + } if hl.boundaryMaxScan != nil { source["boundary_max_scan"] = *hl.boundaryMaxScan } diff --git a/vendor/github.com/olivere/elastic/v7/indices_create.go b/vendor/github.com/olivere/elastic/v7/indices_create.go index 4bcd77bedfbc9a9853c2c5d50082cb60c2b03f68..3457fb4127c2c8ac438b9d0e5fd823e55a1f5684 100644 --- a/vendor/github.com/olivere/elastic/v7/indices_create.go +++ b/vendor/github.com/olivere/elastic/v7/indices_create.go @@ -28,11 +28,12 @@ type IndicesCreateService struct { filterPath []string // list of filters used to reduce the response headers http.Header // custom request-level HTTP headers - index string - timeout string - masterTimeout string - bodyJson interface{} - bodyString string + index string + timeout string + masterTimeout string + includeTypeName *bool + bodyJson interface{} + bodyString string } // NewIndicesCreateService returns a new IndicesCreateService. @@ -98,6 +99,12 @@ func (s *IndicesCreateService) MasterTimeout(masterTimeout string) *IndicesCreat return s } +// IncludeTypeName indicates whether a type should be expected in the body of the mappings. +func (s *IndicesCreateService) IncludeTypeName(includeTypeName bool) *IndicesCreateService { + s.includeTypeName = &includeTypeName + return s +} + // Body specifies the configuration of the index as a string. // It is an alias for BodyString. func (s *IndicesCreateService) Body(body string) *IndicesCreateService { @@ -151,6 +158,9 @@ func (s *IndicesCreateService) Do(ctx context.Context) (*IndicesCreateResult, er if s.timeout != "" { params.Set("timeout", s.timeout) } + if v := s.includeTypeName; v != nil { + params.Set("include_type_name", fmt.Sprint(*v)) + } // Setup HTTP request body var body interface{} diff --git a/vendor/github.com/olivere/elastic/v7/indices_delete_template.go b/vendor/github.com/olivere/elastic/v7/indices_delete_template.go index 7dd5506046f36b1a9d0c89b15c1346b475c46374..aab1250c459c7a6ff04cd9945c9a660b49f3baa8 100644 --- a/vendor/github.com/olivere/elastic/v7/indices_delete_template.go +++ b/vendor/github.com/olivere/elastic/v7/indices_delete_template.go @@ -22,6 +22,8 @@ import ( // // See https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-delete-template-v1.html // for more details. +// +// Deprecated: Legacy index templates are deprecated in favor of composable templates. type IndicesDeleteTemplateService struct { client *Client @@ -147,6 +149,8 @@ func (s *IndicesDeleteTemplateService) Validate() error { } // Do executes the operation. +// +// Deprecated: Legacy index templates are deprecated in favor of composable templates. func (s *IndicesDeleteTemplateService) Do(ctx context.Context) (*IndicesDeleteTemplateResponse, error) { // Check pre-conditions if err := s.Validate(); err != nil { diff --git a/vendor/github.com/olivere/elastic/v7/indices_exists_template.go b/vendor/github.com/olivere/elastic/v7/indices_exists_template.go index 53f29fea6971e84fb665f38b006f62d475ae7c7e..f12d753177f585594c4ea321b6d3350dfc1174a0 100644 --- a/vendor/github.com/olivere/elastic/v7/indices_exists_template.go +++ b/vendor/github.com/olivere/elastic/v7/indices_exists_template.go @@ -17,6 +17,8 @@ import ( // IndicesExistsTemplateService checks if a given template exists. // See http://www.elastic.co/guide/en/elasticsearch/reference/7.0/indices-templates.html#indices-templates-exists // for documentation. +// +// Deprecated: Legacy index templates are deprecated in favor of composable templates. type IndicesExistsTemplateService struct { client *Client @@ -143,6 +145,8 @@ func (s *IndicesExistsTemplateService) Validate() error { } // Do executes the operation. +// +// Deprecated: Legacy index templates are deprecated in favor of composable templates. func (s *IndicesExistsTemplateService) Do(ctx context.Context) (bool, error) { // Check pre-conditions if err := s.Validate(); err != nil { diff --git a/vendor/github.com/olivere/elastic/v7/indices_freeze.go b/vendor/github.com/olivere/elastic/v7/indices_freeze.go index 04c2a3e1588e789d22c531a4decb058bad097ad1..086e8244142bfebcb2ea5bcc40e5868fda68523d 100644 --- a/vendor/github.com/olivere/elastic/v7/indices_freeze.go +++ b/vendor/github.com/olivere/elastic/v7/indices_freeze.go @@ -19,6 +19,9 @@ import ( // See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/freeze-index-api.html // and https://www.elastic.co/blog/creating-frozen-indices-with-the-elasticsearch-freeze-index-api // for details. +// +// Deprecated: Frozen indices are deprecated because they provide no benefit +// given improvements in heap memory utilization. type IndicesFreezeService struct { client *Client @@ -192,6 +195,9 @@ func (s *IndicesFreezeService) Validate() error { } // Do executes the service. +// +// Deprecated: Frozen indices are deprecated because they provide no benefit +// given improvements in heap memory utilization. func (s *IndicesFreezeService) Do(ctx context.Context) (*IndicesFreezeResponse, error) { // Check pre-conditions if err := s.Validate(); err != nil { diff --git a/vendor/github.com/olivere/elastic/v7/indices_get_index_template.go b/vendor/github.com/olivere/elastic/v7/indices_get_index_template.go index 0c3baef23589f8966e2faf61889a545054dc992d..92b4445e31d7273c02c80a9897b0be4292406784 100644 --- a/vendor/github.com/olivere/elastic/v7/indices_get_index_template.go +++ b/vendor/github.com/olivere/elastic/v7/indices_get_index_template.go @@ -191,7 +191,21 @@ func (s *IndicesGetIndexTemplateService) Do(ctx context.Context) (*IndicesGetInd // IndicesGetIndexTemplateResponse is the response of IndicesGetIndexTemplateService.Do. type IndicesGetIndexTemplateResponse struct { - IndexTemplates []IndicesGetIndexTemplates `json:"index_templates"` + IndexTemplates IndicesGetIndexTemplatesSlice `json:"index_templates"` +} + +// IndicesGetIndexTemplatesSlice is a slice of IndicesGetIndexTemplates. +type IndicesGetIndexTemplatesSlice []IndicesGetIndexTemplates + +// ByName returns the template with the given name, if it exists. +// The bool indicates whether a template with that name has been found. +func (slice IndicesGetIndexTemplatesSlice) ByName(name string) (*IndicesGetIndexTemplates, bool) { + for _, t := range slice { + if t.Name == name { + return &t, true + } + } + return nil, false } type IndicesGetIndexTemplates struct { @@ -200,11 +214,14 @@ type IndicesGetIndexTemplates struct { } type IndicesGetIndexTemplate struct { - IndexPatterns []string `json:"index_patterns,omitempty"` - ComposedOf []string `json:"composed_of,omitempty"` - Priority int `json:"priority,omitempty"` - Version int `json:"version,omitempty"` - Template *IndicesGetIndexTemplateData `json:"template,omitempty"` + IndexPatterns []string `json:"index_patterns,omitempty"` + ComposedOf []string `json:"composed_of,omitempty"` + Priority int `json:"priority,omitempty"` + Version int `json:"version,omitempty"` + Template *IndicesGetIndexTemplateData `json:"template,omitempty"` + Meta map[string]interface{} `json:"_meta,omitempty"` + DataStream *IndicesDataStream `json:"data_stream,omitempty"` + AllowAutoCreate bool `json:"allow_auto_create,omitempty"` } type IndicesGetIndexTemplateData struct { @@ -212,3 +229,22 @@ type IndicesGetIndexTemplateData struct { Mappings map[string]interface{} `json:"mappings,omitempty"` Aliases map[string]interface{} `json:"aliases,omitempty"` } + +type IndicesDataStream struct { + Name string `json:"name,omitempty"` + TimestampField *IndicesDataStreamTimestampField `json:"timestamp_field,omitempty"` + Indices []string `json:"indices,omitempty"` + Generation int64 `json:"generation,omitempty"` + Status string `json:"status,omitempty"` + IndexTemplate string `json:"template,omitempty"` + IlmPolicy string `json:"ilm_policy,omitempty"` + Meta map[string]interface{} `json:"_meta,omitempty"` + Hidden bool `json:"hidden,omitempty"` + System bool `json:"system,omitempty"` + AllowCustomRouting bool `json:"allow_custom_routing,omitempty"` + Replicated bool `json:"replicated,omitempty"` +} + +type IndicesDataStreamTimestampField struct { + Name string `json:"name,omitempty"` +} diff --git a/vendor/github.com/olivere/elastic/v7/indices_get_template.go b/vendor/github.com/olivere/elastic/v7/indices_get_template.go index 28bb4a0e5c8f5ee9452e7cf63c153fc69d894e87..756a3ed783b171c329ba8b138aea09ddcfce7de4 100644 --- a/vendor/github.com/olivere/elastic/v7/indices_get_template.go +++ b/vendor/github.com/olivere/elastic/v7/indices_get_template.go @@ -22,6 +22,8 @@ import ( // // See https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-get-template-v1.html // for more details. +// +// Deprecated: Legacy index templates are deprecated in favor of composable templates. type IndicesGetTemplateService struct { client *Client @@ -148,6 +150,8 @@ func (s *IndicesGetTemplateService) Validate() error { } // Do executes the operation. +// +// Deprecated: Legacy index templates are deprecated in favor of composable templates. func (s *IndicesGetTemplateService) Do(ctx context.Context) (map[string]*IndicesGetTemplateResponse, error) { // Check pre-conditions if err := s.Validate(); err != nil { diff --git a/vendor/github.com/olivere/elastic/v7/indices_put_mapping.go b/vendor/github.com/olivere/elastic/v7/indices_put_mapping.go index eae320ac60be34406bfa9369ee2da68cdd928b4d..250ba2f56e850a8dd1eb5d392211f9c60ecdb37e 100644 --- a/vendor/github.com/olivere/elastic/v7/indices_put_mapping.go +++ b/vendor/github.com/olivere/elastic/v7/indices_put_mapping.go @@ -33,7 +33,8 @@ type IndicesPutMappingService struct { ignoreUnavailable *bool allowNoIndices *bool expandWildcards string - updateAllTypes *bool + includeTypeName *bool + writeIndexOnly *bool timeout string bodyJson map[string]interface{} bodyString string @@ -134,10 +135,15 @@ func (s *IndicesPutMappingService) ExpandWildcards(expandWildcards string) *Indi return s } -// UpdateAllTypes, if true, indicates that all fields that span multiple indices -// should be updated (default: false). -func (s *IndicesPutMappingService) UpdateAllTypes(updateAllTypes bool) *IndicesPutMappingService { - s.updateAllTypes = &updateAllTypes +// IncludeTypeName indicates whether a type should be expected in the body of the mappings. +func (s *IndicesPutMappingService) IncludeTypeName(includeTypeName bool) *IndicesPutMappingService { + s.includeTypeName = &includeTypeName + return s +} + +// WriteIndexOnly, when true, applies mappings only to the write index of an alias or data stream. +func (s *IndicesPutMappingService) WriteIndexOnly(writeIndexOnly bool) *IndicesPutMappingService { + s.writeIndexOnly = &writeIndexOnly return s } @@ -177,16 +183,19 @@ func (s *IndicesPutMappingService) buildURL() (string, url.Values, error) { params.Set("filter_path", strings.Join(s.filterPath, ",")) } if s.ignoreUnavailable != nil { - params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable)) + params.Set("ignore_unavailable", fmt.Sprint(*s.ignoreUnavailable)) } if s.allowNoIndices != nil { - params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices)) + params.Set("allow_no_indices", fmt.Sprint(*s.allowNoIndices)) } if s.expandWildcards != "" { params.Set("expand_wildcards", s.expandWildcards) } - if s.updateAllTypes != nil { - params.Set("update_all_types", fmt.Sprintf("%v", *s.updateAllTypes)) + if s.includeTypeName != nil { + params.Set("include_type_name", fmt.Sprint(*s.includeTypeName)) + } + if s.writeIndexOnly != nil { + params.Set("write_index_only", fmt.Sprint(*s.writeIndexOnly)) } if s.timeout != "" { params.Set("timeout", s.timeout) diff --git a/vendor/github.com/olivere/elastic/v7/indices_put_template.go b/vendor/github.com/olivere/elastic/v7/indices_put_template.go index bafa81ed91bc739a36613ff40f6ccf68080368d3..9a42c734afdd05f3f4e1f27bd326b678d6647c38 100644 --- a/vendor/github.com/olivere/elastic/v7/indices_put_template.go +++ b/vendor/github.com/olivere/elastic/v7/indices_put_template.go @@ -22,6 +22,8 @@ import ( // // See https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-templates-v1.html // for more details. +// +// Deprecated: Legacy index templates are deprecated in favor of composable templates. type IndicesPutTemplateService struct { client *Client @@ -31,16 +33,17 @@ type IndicesPutTemplateService struct { filterPath []string // list of filters used to reduce the response headers http.Header // custom request-level HTTP headers - name string - cause string - order interface{} - version *int - create *bool - timeout string - masterTimeout string - flatSettings *bool - bodyJson interface{} - bodyString string + name string + cause string + order interface{} + version *int + create *bool + timeout string + masterTimeout string + flatSettings *bool + includeTypeName *bool + bodyJson interface{} + bodyString string } // NewIndicesPutTemplateService creates a new IndicesPutTemplateService. @@ -115,6 +118,12 @@ func (s *IndicesPutTemplateService) MasterTimeout(masterTimeout string) *Indices return s } +// IncludeTypeName indicates whether a type should be expected in the body of the mappings. +func (s *IndicesPutTemplateService) IncludeTypeName(includeTypeName bool) *IndicesPutTemplateService { + s.includeTypeName = &includeTypeName + return s +} + // FlatSettings indicates whether to return settings in flat format (default: false). func (s *IndicesPutTemplateService) FlatSettings(flatSettings bool) *IndicesPutTemplateService { s.flatSettings = &flatSettings @@ -181,10 +190,10 @@ func (s *IndicesPutTemplateService) buildURL() (string, url.Values, error) { params.Set("order", fmt.Sprintf("%v", s.order)) } if s.version != nil { - params.Set("version", fmt.Sprintf("%v", *s.version)) + params.Set("version", fmt.Sprint(*s.version)) } if s.create != nil { - params.Set("create", fmt.Sprintf("%v", *s.create)) + params.Set("create", fmt.Sprint(*s.create)) } if s.cause != "" { params.Set("cause", s.cause) @@ -196,7 +205,10 @@ func (s *IndicesPutTemplateService) buildURL() (string, url.Values, error) { params.Set("master_timeout", s.masterTimeout) } if s.flatSettings != nil { - params.Set("flat_settings", fmt.Sprintf("%v", *s.flatSettings)) + params.Set("flat_settings", fmt.Sprint(*s.flatSettings)) + } + if s.includeTypeName != nil { + params.Set("include_type_name", fmt.Sprint(*s.includeTypeName)) } return path, params, nil } @@ -217,6 +229,8 @@ func (s *IndicesPutTemplateService) Validate() error { } // Do executes the operation. +// +// Deprecated: Legacy index templates are deprecated in favor of composable templates. func (s *IndicesPutTemplateService) Do(ctx context.Context) (*IndicesPutTemplateResponse, error) { // Check pre-conditions if err := s.Validate(); err != nil { diff --git a/vendor/github.com/olivere/elastic/v7/indices_refresh.go b/vendor/github.com/olivere/elastic/v7/indices_refresh.go index 4dfdbe40fed22d89453d6db7d6eebc40c919415a..8593d55781379ecbb467af22429b924e8cd9058e 100644 --- a/vendor/github.com/olivere/elastic/v7/indices_refresh.go +++ b/vendor/github.com/olivere/elastic/v7/indices_refresh.go @@ -145,5 +145,5 @@ func (s *RefreshService) Do(ctx context.Context) (*RefreshResult, error) { // RefreshResult is the outcome of RefreshService.Do. type RefreshResult struct { - Shards *ShardsInfo `json:"_shards,omitempty"` + BroadcastResponse } diff --git a/vendor/github.com/olivere/elastic/v7/indices_stats.go b/vendor/github.com/olivere/elastic/v7/indices_stats.go index 397d63861106095a4cb20a9557225b9aecb22c86..8296c8213e9f83e1a5dddda796bf0e27d1fce966 100644 --- a/vendor/github.com/olivere/elastic/v7/indices_stats.go +++ b/vendor/github.com/olivere/elastic/v7/indices_stats.go @@ -285,6 +285,7 @@ type IndexStatsDetails struct { SeqNo *IndexStatsSeqNo `json:"seq_no,omitempty"` RetentionLeases *IndexStatsRetentionLeases `json:"retention_leases,omitempty"` ShardPath *IndexStatsShardPath `json:"shard_path,omitempty"` + ShardStats *IndexStatsShardStats `json:"shard_stats,omitempty"` } type IndexStatsRouting struct { @@ -300,14 +301,22 @@ type IndexStatsShardPath struct { IsCustomDataPath bool `json:"is_custom_data_path"` } +type IndexStatsShardStats struct { + TotalCount int64 `json:"total_count,omitempty"` +} + type IndexStatsDocs struct { Count int64 `json:"count,omitempty"` Deleted int64 `json:"deleted,omitempty"` } type IndexStatsStore struct { - Size string `json:"size,omitempty"` // human size, e.g. 119.3mb - SizeInBytes int64 `json:"size_in_bytes,omitempty"` + Size string `json:"size,omitempty"` // human size, e.g. 119.3mb + SizeInBytes int64 `json:"size_in_bytes,omitempty"` + TotalDataSetSize string `json:"total_data_set_size,omitempty"` + TotalDataSetSizeInBytes int64 `json:"total_data_set_size_in_bytes,omitempty"` + Reserved string `json:"reserved,omitempty"` + ReservedInBytes int64 `json:"reserved_in_bytes,omitempty"` } type IndexStatsIndexing struct { diff --git a/vendor/github.com/olivere/elastic/v7/indices_unfreeze.go b/vendor/github.com/olivere/elastic/v7/indices_unfreeze.go index 3da75d4fd7ab6214b46d4613664c3531cba7005e..5945eb15287e958922c47d3f69e982fb87ec72f7 100644 --- a/vendor/github.com/olivere/elastic/v7/indices_unfreeze.go +++ b/vendor/github.com/olivere/elastic/v7/indices_unfreeze.go @@ -19,6 +19,9 @@ import ( // See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/unfreeze-index-api.html // and https://www.elastic.co/blog/creating-frozen-indices-with-the-elasticsearch-freeze-index-api // for details. +// +// Deprecated: Frozen indices are deprecated because they provide no benefit +// given improvements in heap memory utilization. type IndicesUnfreezeService struct { client *Client @@ -192,6 +195,9 @@ func (s *IndicesUnfreezeService) Validate() error { } // Do executes the service. +// +// Deprecated: Frozen indices are deprecated because they provide no benefit +// given improvements in heap memory utilization. func (s *IndicesUnfreezeService) Do(ctx context.Context) (*IndicesUnfreezeResponse, error) { // Check pre-conditions if err := s.Validate(); err != nil { diff --git a/vendor/github.com/olivere/elastic/v7/nodes_stats.go b/vendor/github.com/olivere/elastic/v7/nodes_stats.go index a57651e3be339c6fb443c7b1a9eb7dc9b6f8c5ea..783bd5e92ce1977d30f111baabee9b828edb951e 100644 --- a/vendor/github.com/olivere/elastic/v7/nodes_stats.go +++ b/vendor/github.com/olivere/elastic/v7/nodes_stats.go @@ -333,6 +333,7 @@ type NodesStatsNode struct { type NodesStatsIndex struct { Docs *NodesStatsDocsStats `json:"docs"` + Shards *NodesStatsShardCountStats `json:"shards_stats"` Store *NodesStatsStoreStats `json:"store"` Indexing *NodesStatsIndexingStats `json:"indexing"` Get *NodesStatsGetStats `json:"get"` @@ -343,16 +344,14 @@ type NodesStatsIndex struct { Warmer *NodesStatsWarmerStats `json:"warmer"` QueryCache *NodesStatsQueryCacheStats `json:"query_cache"` Fielddata *NodesStatsFielddataStats `json:"fielddata"` - Percolate *NodesStatsPercolateStats `json:"percolate"` Completion *NodesStatsCompletionStats `json:"completion"` Segments *NodesStatsSegmentsStats `json:"segments"` Translog *NodesStatsTranslogStats `json:"translog"` - Suggest *NodesStatsSuggestStats `json:"suggest"` RequestCache *NodesStatsRequestCacheStats `json:"request_cache"` Recovery NodesStatsRecoveryStats `json:"recovery"` - Indices map[string]*NodesStatsIndex `json:"indices"` // for level=indices - Shards map[string]*NodesStatsIndex `json:"shards"` // for level=shards + IndicesLevel map[string]*NodesStatsIndex `json:"indices"` // for level=indices + ShardsLevel map[string]*NodesStatsIndex `json:"shards"` // for level=shards } type NodesStatsDocsStats struct { @@ -360,6 +359,10 @@ type NodesStatsDocsStats struct { Deleted int64 `json:"deleted"` } +type NodesStatsShardCountStats struct { + TotalCount int64 `json:"total_count"` +} + type NodesStatsStoreStats struct { Size string `json:"size"` SizeInBytes int64 `json:"size_in_bytes"` @@ -473,16 +476,6 @@ type NodesStatsFielddataStats struct { } `json:"fields"` } -type NodesStatsPercolateStats struct { - Total int64 `json:"total"` - Time string `json:"time"` - TimeInMillis int64 `json:"time_in_millis"` - Current int64 `json:"current"` - MemorySize string `json:"memory_size"` - MemorySizeInBytes int64 `json:"memory_size_in_bytes"` - Queries int64 `json:"queries"` -} - type NodesStatsCompletionStats struct { Size string `json:"size"` SizeInBytes int64 `json:"size_in_bytes"` @@ -522,13 +515,6 @@ type NodesStatsTranslogStats struct { SizeInBytes int64 `json:"size_in_bytes"` } -type NodesStatsSuggestStats struct { - Total int64 `json:"total"` - TotalTime string `json:"total_time"` - TotalTimeInMillis int64 `json:"total_time_in_millis"` - Current int64 `json:"current"` -} - type NodesStatsRequestCacheStats struct { MemorySize string `json:"memory_size"` MemorySizeInBytes int64 `json:"memory_size_in_bytes"` diff --git a/vendor/github.com/olivere/elastic/v7/pit.go b/vendor/github.com/olivere/elastic/v7/pit.go index 22871309ccdef48f3dc20f3883dc1057d210bac7..49ecb9cac0fa86c8eb515b9d565955936f6859c7 100644 --- a/vendor/github.com/olivere/elastic/v7/pit.go +++ b/vendor/github.com/olivere/elastic/v7/pit.go @@ -17,7 +17,15 @@ type PointInTime struct { } // NewPointInTime creates a new PointInTime. -func NewPointInTime(id, keepAlive string) *PointInTime { +func NewPointInTime(id string) *PointInTime { + return &PointInTime{ + Id: id, + } +} + +// NewPointInTimeWithKeepAlive creates a new PointInTime with the given +// time to keep alive. +func NewPointInTimeWithKeepAlive(id, keepAlive string) *PointInTime { return &PointInTime{ Id: id, KeepAlive: keepAlive, @@ -29,8 +37,11 @@ func (pit *PointInTime) Source() (interface{}, error) { if pit == nil { return nil, nil } - return map[string]interface{}{ - "id": pit.Id, - "keep_alive": pit.KeepAlive, - }, nil + m := map[string]interface{}{ + "id": pit.Id, + } + if pit.KeepAlive != "" { + m["keep_alive"] = pit.KeepAlive + } + return m, nil } diff --git a/vendor/github.com/olivere/elastic/v7/runtime_mappings.go b/vendor/github.com/olivere/elastic/v7/runtime_mappings.go new file mode 100644 index 0000000000000000000000000000000000000000..28eafc00cb722b0e9d405f9161e07c7316beede3 --- /dev/null +++ b/vendor/github.com/olivere/elastic/v7/runtime_mappings.go @@ -0,0 +1,16 @@ +// Copyright 2012-present Oliver Eilhard. All rights reserved. +// Use of this source code is governed by a MIT-license. +// See http://olivere.mit-license.org/license.txt for details. + +package elastic + +// RuntimeMappings specify fields that are evaluated at query time. +// +// See https://www.elastic.co/guide/en/elasticsearch/reference/7.14/runtime.html +// for details. +type RuntimeMappings map[string]interface{} + +// Source deserializes the runtime mappings. +func (m *RuntimeMappings) Source() (interface{}, error) { + return m, nil +} diff --git a/vendor/github.com/olivere/elastic/v7/search.go b/vendor/github.com/olivere/elastic/v7/search.go index 6e0b476ac74725b46223bab88175730e14632ae3..4745c1b8d9044cf561f0e8436b9df0c370a54cda 100644 --- a/vendor/github.com/olivere/elastic/v7/search.go +++ b/vendor/github.com/olivere/elastic/v7/search.go @@ -159,6 +159,12 @@ func (s *SearchService) PointInTime(pointInTime *PointInTime) *SearchService { return s } +// RuntimeMappings specifies optional runtime mappings. +func (s *SearchService) RuntimeMappings(runtimeMappings RuntimeMappings) *SearchService { + s.searchSource = s.searchSource.RuntimeMappings(runtimeMappings) + return s +} + // TimeoutInMillis sets the timeout in milliseconds. func (s *SearchService) TimeoutInMillis(timeoutInMillis int) *SearchService { s.searchSource = s.searchSource.TimeoutInMillis(timeoutInMillis) @@ -452,9 +458,16 @@ func (s *SearchService) TypedKeys(enabled bool) *SearchService { return s } -// SeqNoPrimaryTerm specifies whether to return sequence number and -// primary term of the last modification of each hit. +// SeqNoPrimaryTerm is an alias for SeqNoAndPrimaryTerm. +// +// Deprecated: Use SeqNoAndPrimaryTerm. func (s *SearchService) SeqNoPrimaryTerm(enabled bool) *SearchService { + return s.SeqNoAndPrimaryTerm(enabled) +} + +// SeqNoAndPrimaryTerm specifies whether to return sequence number and +// primary term of the last modification of each hit. +func (s *SearchService) SeqNoAndPrimaryTerm(enabled bool) *SearchService { s.seqNoPrimaryTerm = &enabled return s } @@ -764,7 +777,7 @@ type SearchHit struct { Sort []interface{} `json:"sort,omitempty"` // sort information Highlight SearchHitHighlight `json:"highlight,omitempty"` // highlighter information Source json.RawMessage `json:"_source,omitempty"` // stored document source - Fields map[string]interface{} `json:"fields,omitempty"` // returned (stored) fields + Fields SearchHitFields `json:"fields,omitempty"` // returned (stored) fields Explanation *SearchExplanation `json:"_explanation,omitempty"` // explains how the score was computed MatchedQueries []string `json:"matched_queries,omitempty"` // matched queries InnerHits map[string]*SearchHitInnerHits `json:"inner_hits,omitempty"` // inner hits with ES >= 1.5.0 @@ -777,6 +790,43 @@ type SearchHit struct { // MatchedFilters } +// SearchHitFields helps to simplify resolving slices of specific types. +type SearchHitFields map[string]interface{} + +// Strings returns a slice of strings for the given field, if there is any +// such field in the hit. The method ignores elements that are not of type +// string. +func (f SearchHitFields) Strings(fieldName string) ([]string, bool) { + slice, ok := f[fieldName].([]interface{}) + if !ok { + return nil, false + } + results := make([]string, 0, len(slice)) + for _, item := range slice { + if v, ok := item.(string); ok { + results = append(results, v) + } + } + return results, true +} + +// Float64s returns a slice of float64's for the given field, if there is any +// such field in the hit. The method ignores elements that are not of +// type float64. +func (f SearchHitFields) Float64s(fieldName string) ([]float64, bool) { + slice, ok := f[fieldName].([]interface{}) + if !ok { + return nil, false + } + results := make([]float64, 0, len(slice)) + for _, item := range slice { + if v, ok := item.(float64); ok { + results = append(results, v) + } + } + return results, true +} + // SearchHitInnerHits is used for inner hits. type SearchHitInnerHits struct { Hits *SearchHits `json:"hits,omitempty"` @@ -833,6 +883,7 @@ type SearchProfileShardResult struct { ID string `json:"id"` Searches []QueryProfileShardResult `json:"searches"` Aggregations []ProfileResult `json:"aggregations"` + Fetch *ProfileResult `json:"fetch"` } // QueryProfileShardResult is a container class to hold the profile results @@ -858,12 +909,13 @@ type CollectorResult struct { // ProfileResult is the internal representation of a profiled query, // corresponding to a single node in the query tree. type ProfileResult struct { - Type string `json:"type"` - Description string `json:"description,omitempty"` - NodeTime string `json:"time,omitempty"` - NodeTimeNanos int64 `json:"time_in_nanos,omitempty"` - Breakdown map[string]int64 `json:"breakdown,omitempty"` - Children []ProfileResult `json:"children,omitempty"` + Type string `json:"type"` + Description string `json:"description,omitempty"` + NodeTime string `json:"time,omitempty"` + NodeTimeNanos int64 `json:"time_in_nanos,omitempty"` + Breakdown map[string]int64 `json:"breakdown,omitempty"` + Children []ProfileResult `json:"children,omitempty"` + Debug map[string]interface{} `json:"debug,omitempty"` } // Aggregations (see search_aggs.go) diff --git a/vendor/github.com/olivere/elastic/v7/search_aggs_bucket_sampler.go b/vendor/github.com/olivere/elastic/v7/search_aggs_bucket_sampler.go index d64e6b3dd661217402666a93f44ce3625f731023..943c70dde3b80dd9f05b3ddd8e66be2ddaf7ba7a 100644 --- a/vendor/github.com/olivere/elastic/v7/search_aggs_bucket_sampler.go +++ b/vendor/github.com/olivere/elastic/v7/search_aggs_bucket_sampler.go @@ -14,15 +14,12 @@ type SamplerAggregation struct { subAggregations map[string]Aggregation meta map[string]interface{} - shardSize int - maxDocsPerValue int - executionHint string + shardSize int } func NewSamplerAggregation() *SamplerAggregation { return &SamplerAggregation{ shardSize: -1, - maxDocsPerValue: -1, subAggregations: make(map[string]Aggregation), } } @@ -44,16 +41,6 @@ func (a *SamplerAggregation) ShardSize(shardSize int) *SamplerAggregation { return a } -func (a *SamplerAggregation) MaxDocsPerValue(maxDocsPerValue int) *SamplerAggregation { - a.maxDocsPerValue = maxDocsPerValue - return a -} - -func (a *SamplerAggregation) ExecutionHint(hint string) *SamplerAggregation { - a.executionHint = hint - return a -} - func (a *SamplerAggregation) Source() (interface{}, error) { // Example: // { @@ -82,12 +69,6 @@ func (a *SamplerAggregation) Source() (interface{}, error) { if a.shardSize >= 0 { opts["shard_size"] = a.shardSize } - if a.maxDocsPerValue >= 0 { - opts["max_docs_per_value"] = a.maxDocsPerValue - } - if a.executionHint != "" { - opts["execution_hint"] = a.executionHint - } // AggregationBuilder (SubAggregations) if len(a.subAggregations) > 0 { diff --git a/vendor/github.com/olivere/elastic/v7/search_collapse_builder.go b/vendor/github.com/olivere/elastic/v7/search_collapse_builder.go index 0de4eed616ccb69e3451c34f897be252cfa95127..b9488a5669d945b94d70a11c1011bbe5f108b57b 100644 --- a/vendor/github.com/olivere/elastic/v7/search_collapse_builder.go +++ b/vendor/github.com/olivere/elastic/v7/search_collapse_builder.go @@ -9,7 +9,7 @@ package elastic // for details. type CollapseBuilder struct { field string - innerHit *InnerHit + innerHits []*InnerHit maxConcurrentGroupRequests *int } @@ -25,8 +25,8 @@ func (b *CollapseBuilder) Field(field string) *CollapseBuilder { } // InnerHit option to expand the collapsed results. -func (b *CollapseBuilder) InnerHit(innerHit *InnerHit) *CollapseBuilder { - b.innerHit = innerHit +func (b *CollapseBuilder) InnerHit(innerHits ...*InnerHit) *CollapseBuilder { + b.innerHits = append(b.innerHits, innerHits...) return b } @@ -41,23 +41,27 @@ func (b *CollapseBuilder) MaxConcurrentGroupRequests(max int) *CollapseBuilder { func (b *CollapseBuilder) Source() (interface{}, error) { // { // "field": "user", - // "inner_hits": { + // "inner_hits": [{ // "name": "last_tweets", // "size": 5, // "sort": [{ "date": "asc" }] - // }, + // }], // "max_concurrent_group_searches": 4 // } src := map[string]interface{}{ "field": b.field, } - if b.innerHit != nil { - hits, err := b.innerHit.Source() - if err != nil { - return nil, err + if len(b.innerHits) > 0 { + var innerHits []interface{} + for _, h := range b.innerHits { + hits, err := h.Source() + if err != nil { + return nil, err + } + innerHits = append(innerHits, hits) } - src["inner_hits"] = hits + src["inner_hits"] = innerHits } if b.maxConcurrentGroupRequests != nil { diff --git a/vendor/github.com/olivere/elastic/v7/search_queries_combined_fields.go b/vendor/github.com/olivere/elastic/v7/search_queries_combined_fields.go new file mode 100644 index 0000000000000000000000000000000000000000..aa4df6d213a74a133cc0826b4e4a7254606b485d --- /dev/null +++ b/vendor/github.com/olivere/elastic/v7/search_queries_combined_fields.go @@ -0,0 +1,110 @@ +// Copyright 2012-present Oliver Eilhard. All rights reserved. +// Use of this source code is governed by a MIT-license. +// See http://olivere.mit-license.org/license.txt for details. + +package elastic + +import "fmt" + +// CombinedFieldsQuery supports searching multiple text fields as if their +// contents had been indexed into one combined field. +// +// For more details, see +// https://www.elastic.co/guide/en/elasticsearch/reference/7.13/query-dsl-combined-fields-query.html +type CombinedFieldsQuery struct { + text interface{} + fields []string + fieldBoosts map[string]*float64 + autoGenerateSynonymsPhraseQuery *bool + operator string // AND or OR + minimumShouldMatch string + zeroTermsQuery string +} + +// NewCombinedFieldsQuery creates and initializes a new CombinedFieldsQuery. +func NewCombinedFieldsQuery(text interface{}, fields ...string) *CombinedFieldsQuery { + q := &CombinedFieldsQuery{ + text: text, + fieldBoosts: make(map[string]*float64), + } + q.fields = append(q.fields, fields...) + return q +} + +// Field adds a field to run the multi match against. +func (q *CombinedFieldsQuery) Field(field string) *CombinedFieldsQuery { + q.fields = append(q.fields, field) + return q +} + +// FieldWithBoost adds a field to run the multi match against with a specific boost. +func (q *CombinedFieldsQuery) FieldWithBoost(field string, boost float64) *CombinedFieldsQuery { + q.fields = append(q.fields, field) + q.fieldBoosts[field] = &boost + return q +} + +// AutoGenerateSynonymsPhraseQuery indicates whether phrase queries should be +// automatically generated for multi terms synonyms. Defaults to true. +func (q *CombinedFieldsQuery) AutoGenerateSynonymsPhraseQuery(enable bool) *CombinedFieldsQuery { + q.autoGenerateSynonymsPhraseQuery = &enable + return q +} + +// Operator sets the operator to use when using boolean query. +// It can be either AND or OR (default). +func (q *CombinedFieldsQuery) Operator(operator string) *CombinedFieldsQuery { + q.operator = operator + return q +} + +// MinimumShouldMatch represents the minimum number of optional should clauses +// to match. +func (q *CombinedFieldsQuery) MinimumShouldMatch(minimumShouldMatch string) *CombinedFieldsQuery { + q.minimumShouldMatch = minimumShouldMatch + return q +} + +// ZeroTermsQuery can be "all" or "none". +func (q *CombinedFieldsQuery) ZeroTermsQuery(zeroTermsQuery string) *CombinedFieldsQuery { + q.zeroTermsQuery = zeroTermsQuery + return q +} + +// Source returns JSON for the query. +func (q *CombinedFieldsQuery) Source() (interface{}, error) { + source := make(map[string]interface{}) + + combinedFields := make(map[string]interface{}) + source["combined_fields"] = combinedFields + + combinedFields["query"] = q.text + + fields := []string{} + for _, field := range q.fields { + if boost, found := q.fieldBoosts[field]; found { + if boost != nil { + fields = append(fields, fmt.Sprintf("%s^%f", field, *boost)) + } else { + fields = append(fields, field) + } + } else { + fields = append(fields, field) + } + } + combinedFields["fields"] = fields + + if q.autoGenerateSynonymsPhraseQuery != nil { + combinedFields["auto_generate_synonyms_phrase_query"] = q.autoGenerateSynonymsPhraseQuery + } + if q.operator != "" { + combinedFields["operator"] = q.operator + } + if q.minimumShouldMatch != "" { + combinedFields["minimum_should_match"] = q.minimumShouldMatch + } + if q.zeroTermsQuery != "" { + combinedFields["zero_terms_query"] = q.zeroTermsQuery + } + return source, nil +} diff --git a/vendor/github.com/olivere/elastic/v7/search_queries_common_terms.go b/vendor/github.com/olivere/elastic/v7/search_queries_common_terms.go index a10a213bcb5d1687dd51a04abfe00aefe450f944..f9dd9f42395ca94801bc9a0b6872463bde4e83c5 100644 --- a/vendor/github.com/olivere/elastic/v7/search_queries_common_terms.go +++ b/vendor/github.com/olivere/elastic/v7/search_queries_common_terms.go @@ -30,6 +30,8 @@ type CommonTermsQuery struct { } // NewCommonTermsQuery creates and initializes a new common terms query. +// +// Deprecated: Common Terms Query was deprecated in >= 7.3.0. See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html. func NewCommonTermsQuery(name string, text interface{}) *CommonTermsQuery { return &CommonTermsQuery{name: name, text: text} } diff --git a/vendor/github.com/olivere/elastic/v7/search_queries_geo_bounding_box.go b/vendor/github.com/olivere/elastic/v7/search_queries_geo_bounding_box.go index 6345867f698bc5ed33c570cee1e7e13cdb77b2de..8e6dd3f9a66fe7f86b361a2545cf580d9df86fb4 100644 --- a/vendor/github.com/olivere/elastic/v7/search_queries_geo_bounding_box.go +++ b/vendor/github.com/olivere/elastic/v7/search_queries_geo_bounding_box.go @@ -4,21 +4,22 @@ package elastic -import "errors" - // GeoBoundingBoxQuery allows to filter hits based on a point location using // a bounding box. // // For more details, see: // https://www.elastic.co/guide/en/elasticsearch/reference/7.0/query-dsl-geo-bounding-box-query.html type GeoBoundingBoxQuery struct { - name string - top *float64 - left *float64 - bottom *float64 - right *float64 - typ string - queryName string + name string + topLeft interface{} // can be a GeoPoint, a GeoHash (string), or a lat/lon pair as float64 + topRight interface{} + bottomRight interface{} // can be a GeoPoint, a GeoHash (string), or a lat/lon pair as float64 + bottomLeft interface{} + wkt interface{} + typ string + validationMethod string + ignoreUnmapped *bool + queryName string } // NewGeoBoundingBoxQuery creates and initializes a new GeoBoundingBoxQuery. @@ -28,46 +29,81 @@ func NewGeoBoundingBoxQuery(name string) *GeoBoundingBoxQuery { } } +// TopLeft position from longitude (left) and latitude (top). func (q *GeoBoundingBoxQuery) TopLeft(top, left float64) *GeoBoundingBoxQuery { - q.top = &top - q.left = &left + q.topLeft = []float64{left, top} return q } +// TopLeftFromGeoPoint from a GeoPoint. func (q *GeoBoundingBoxQuery) TopLeftFromGeoPoint(point *GeoPoint) *GeoBoundingBoxQuery { return q.TopLeft(point.Lat, point.Lon) } +// TopLeftFromGeoHash from a Geo hash. +func (q *GeoBoundingBoxQuery) TopLeftFromGeoHash(topLeft string) *GeoBoundingBoxQuery { + q.topLeft = topLeft + return q +} + +// BottomRight position from longitude (right) and latitude (bottom). func (q *GeoBoundingBoxQuery) BottomRight(bottom, right float64) *GeoBoundingBoxQuery { - q.bottom = &bottom - q.right = &right + q.bottomRight = []float64{right, bottom} return q } +// BottomRightFromGeoPoint from a GeoPoint. func (q *GeoBoundingBoxQuery) BottomRightFromGeoPoint(point *GeoPoint) *GeoBoundingBoxQuery { return q.BottomRight(point.Lat, point.Lon) } +// BottomRightFromGeoHash from a Geo hash. +func (q *GeoBoundingBoxQuery) BottomRightFromGeoHash(bottomRight string) *GeoBoundingBoxQuery { + q.bottomRight = bottomRight + return q +} + +// BottomLeft position from longitude (left) and latitude (bottom). func (q *GeoBoundingBoxQuery) BottomLeft(bottom, left float64) *GeoBoundingBoxQuery { - q.bottom = &bottom - q.left = &left + q.bottomLeft = []float64{bottom, left} return q } +// BottomLeftFromGeoPoint from a GeoPoint. func (q *GeoBoundingBoxQuery) BottomLeftFromGeoPoint(point *GeoPoint) *GeoBoundingBoxQuery { return q.BottomLeft(point.Lat, point.Lon) } +// BottomLeftFromGeoHash from a Geo hash. +func (q *GeoBoundingBoxQuery) BottomLeftFromGeoHash(bottomLeft string) *GeoBoundingBoxQuery { + q.bottomLeft = bottomLeft + return q +} + +// TopRight position from longitude (right) and latitude (top). func (q *GeoBoundingBoxQuery) TopRight(top, right float64) *GeoBoundingBoxQuery { - q.top = &top - q.right = &right + q.topRight = []float64{right, top} return q } +// TopRightFromGeoPoint from a GeoPoint. func (q *GeoBoundingBoxQuery) TopRightFromGeoPoint(point *GeoPoint) *GeoBoundingBoxQuery { return q.TopRight(point.Lat, point.Lon) } +// TopRightFromGeoHash from a Geo hash. +func (q *GeoBoundingBoxQuery) TopRightFromGeoHash(topRight string) *GeoBoundingBoxQuery { + q.topRight = topRight + return q +} + +// WKT initializes the bounding box from Well-Known Text (WKT), +// e.g. "BBOX (-74.1, -71.12, 40.73, 40.01)". +func (q *GeoBoundingBoxQuery) WKT(wkt interface{}) *GeoBoundingBoxQuery { + q.wkt = wkt + return q +} + // Type sets the type of executing the geo bounding box. It can be either // memory or indexed. It defaults to memory. func (q *GeoBoundingBoxQuery) Type(typ string) *GeoBoundingBoxQuery { @@ -75,6 +111,22 @@ func (q *GeoBoundingBoxQuery) Type(typ string) *GeoBoundingBoxQuery { return q } +// ValidationMethod accepts IGNORE_MALFORMED, COERCE, and STRICT (default). +// IGNORE_MALFORMED accepts geo points with invalid lat/lon. +// COERCE tries to infer the correct lat/lon. +func (q *GeoBoundingBoxQuery) ValidationMethod(method string) *GeoBoundingBoxQuery { + q.validationMethod = method + return q +} + +// IgnoreUnmapped indicates whether to ignore unmapped fields (and run a +// MatchNoDocsQuery in place of this). +func (q *GeoBoundingBoxQuery) IgnoreUnmapped(ignoreUnmapped bool) *GeoBoundingBoxQuery { + q.ignoreUnmapped = &ignoreUnmapped + return q +} + +// QueryName gives the query a name. It is used for caching. func (q *GeoBoundingBoxQuery) QueryName(queryName string) *GeoBoundingBoxQuery { q.queryName = queryName return q @@ -88,31 +140,38 @@ func (q *GeoBoundingBoxQuery) Source() (interface{}, error) { // } // } - if q.top == nil { - return nil, errors.New("geo_bounding_box requires top latitude to be set") - } - if q.bottom == nil { - return nil, errors.New("geo_bounding_box requires bottom latitude to be set") - } - if q.right == nil { - return nil, errors.New("geo_bounding_box requires right longitude to be set") - } - if q.left == nil { - return nil, errors.New("geo_bounding_box requires left longitude to be set") - } - source := make(map[string]interface{}) params := make(map[string]interface{}) source["geo_bounding_box"] = params box := make(map[string]interface{}) - box["top_left"] = []float64{*q.left, *q.top} - box["bottom_right"] = []float64{*q.right, *q.bottom} + if q.wkt != nil { + box["wkt"] = q.wkt + } else { + if q.topLeft != nil { + box["top_left"] = q.topLeft + } + if q.topRight != nil { + box["top_right"] = q.topRight + } + if q.bottomLeft != nil { + box["bottom_left"] = q.bottomLeft + } + if q.bottomRight != nil { + box["bottom_right"] = q.bottomRight + } + } params[q.name] = box if q.typ != "" { params["type"] = q.typ } + if q.validationMethod != "" { + params["validation_method"] = q.validationMethod + } + if q.ignoreUnmapped != nil { + params["ignore_unmapped"] = *q.ignoreUnmapped + } if q.queryName != "" { params["_name"] = q.queryName } diff --git a/vendor/github.com/olivere/elastic/v7/search_queries_interval_rules_fuzzy.go b/vendor/github.com/olivere/elastic/v7/search_queries_interval_rules_fuzzy.go new file mode 100644 index 0000000000000000000000000000000000000000..37869a63ec3868a64bd578e74ea499927756eea0 --- /dev/null +++ b/vendor/github.com/olivere/elastic/v7/search_queries_interval_rules_fuzzy.go @@ -0,0 +1,91 @@ +package elastic + +var ( + _ IntervalQueryRule = (*IntervalQueryRuleFuzzy)(nil) +) + +// IntervalQueryRuleFuzzy is an implementation of IntervalQueryRule. +// +// See https://www.elastic.co/guide/en/elasticsearch/reference/7.16/query-dsl-intervals-query.html#intervals-fuzzy +// for details. +type IntervalQueryRuleFuzzy struct { + term string + prefixLength *int + transpositions *bool + fuzziness interface{} + analyzer string + useField string +} + +// NewIntervalQueryRuleFuzzy initializes and returns a new instance +// of IntervalQueryRuleFuzzy. +func NewIntervalQueryRuleFuzzy(term string) *IntervalQueryRuleFuzzy { + return &IntervalQueryRuleFuzzy{term: term} +} + +// PrefixLength is the number of beginning characters left unchanged when +// creating expansions. Defaults to 0. +func (q *IntervalQueryRuleFuzzy) PrefixLength(prefixLength int) *IntervalQueryRuleFuzzy { + q.prefixLength = &prefixLength + return q +} + +// Fuzziness is the maximum edit distance allowed for matching. +// It can be integers like 0, 1 or 2 as well as strings +// like "auto", "0..1", "1..4" or "0.0..1.0". Defaults to "auto". +func (q *IntervalQueryRuleFuzzy) Fuzziness(fuzziness interface{}) *IntervalQueryRuleFuzzy { + q.fuzziness = fuzziness + return q +} + +// Transpositions indicates whether edits include transpositions of two +// adjacent characters (ab -> ba). Defaults to true. +func (q *IntervalQueryRuleFuzzy) Transpositions(transpositions bool) *IntervalQueryRuleFuzzy { + q.transpositions = &transpositions + return q +} + +// Analyzer specifies the analyzer used to analyze terms in the query. +func (r *IntervalQueryRuleFuzzy) Analyzer(analyzer string) *IntervalQueryRuleFuzzy { + r.analyzer = analyzer + return r +} + +// UseField, if specified, matches the intervals from this field rather than +// the top-level field. +func (r *IntervalQueryRuleFuzzy) UseField(useField string) *IntervalQueryRuleFuzzy { + r.useField = useField + return r +} + +// Source returns JSON for the function score query. +func (r *IntervalQueryRuleFuzzy) Source() (interface{}, error) { + source := make(map[string]interface{}) + + source["term"] = r.term + + if r.prefixLength != nil { + source["prefix_length"] = *r.prefixLength + } + if r.transpositions != nil { + source["transpositions"] = *r.transpositions + } + if r.fuzziness != "" { + source["fuzziness"] = r.fuzziness + } + if r.analyzer != "" { + source["analyzer"] = r.analyzer + } + if r.useField != "" { + source["use_field"] = r.useField + } + + return map[string]interface{}{ + "fuzzy": source, + }, nil +} + +// isIntervalQueryRule implements the marker interface. +func (r *IntervalQueryRuleFuzzy) isIntervalQueryRule() bool { + return true +} diff --git a/vendor/github.com/olivere/elastic/v7/search_queries_interval_rules_prefix.go b/vendor/github.com/olivere/elastic/v7/search_queries_interval_rules_prefix.go index 7eea791893817ff2a085671890ba6c95c0e0a74b..9e4cfc698403958fad1b2794fe6d3cbd545d83cd 100644 --- a/vendor/github.com/olivere/elastic/v7/search_queries_interval_rules_prefix.go +++ b/vendor/github.com/olivere/elastic/v7/search_queries_interval_rules_prefix.go @@ -37,7 +37,7 @@ func (r *IntervalQueryRulePrefix) UseField(useField string) *IntervalQueryRulePr func (r *IntervalQueryRulePrefix) Source() (interface{}, error) { source := make(map[string]interface{}) - source["query"] = r.prefix + source["prefix"] = r.prefix if r.analyzer != "" { source["analyzer"] = r.analyzer diff --git a/vendor/github.com/olivere/elastic/v7/search_queries_match_all.go b/vendor/github.com/olivere/elastic/v7/search_queries_match_all.go index 921ead5859a168ea612b91c91262728f24796421..96a22f8cff36686cad3824ecddba73c7e1fbaae6 100644 --- a/vendor/github.com/olivere/elastic/v7/search_queries_match_all.go +++ b/vendor/github.com/olivere/elastic/v7/search_queries_match_all.go @@ -4,6 +4,8 @@ package elastic +import "encoding/json" + // MatchAllQuery is the most simple query, which matches all documents, // giving them all a _score of 1.0. // @@ -34,7 +36,7 @@ func (q *MatchAllQuery) QueryName(name string) *MatchAllQuery { } // Source returns JSON for the match all query. -func (q MatchAllQuery) Source() (interface{}, error) { +func (q *MatchAllQuery) Source() (interface{}, error) { // { // "match_all" : { ... } // } @@ -49,3 +51,15 @@ func (q MatchAllQuery) Source() (interface{}, error) { } return source, nil } + +// MarshalJSON enables serializing the type as JSON. +func (q *MatchAllQuery) MarshalJSON() ([]byte, error) { + if q == nil { + return nilByte, nil + } + src, err := q.Source() + if err != nil { + return nil, err + } + return json.Marshal(src) +} diff --git a/vendor/github.com/olivere/elastic/v7/search_queries_prefix.go b/vendor/github.com/olivere/elastic/v7/search_queries_prefix.go index 5e9813e197cbe1bb5ac1e9f1e52426a144187026..7c3f122abd603bc4de412c73a1a661c6fd363eed 100644 --- a/vendor/github.com/olivere/elastic/v7/search_queries_prefix.go +++ b/vendor/github.com/olivere/elastic/v7/search_queries_prefix.go @@ -52,7 +52,7 @@ func (q *PrefixQuery) Source() (interface{}, error) { query := make(map[string]interface{}) source["prefix"] = query - if q.boost == nil && q.rewrite == "" && q.queryName == "" { + if q.boost == nil && q.rewrite == "" && q.queryName == "" && q.caseInsensitive == nil { query[q.name] = q.prefix } else { subQuery := make(map[string]interface{}) diff --git a/vendor/github.com/olivere/elastic/v7/search_queries_rank_feature.go b/vendor/github.com/olivere/elastic/v7/search_queries_rank_feature.go new file mode 100644 index 0000000000000000000000000000000000000000..5a9bdcfabd4eac384eb6faf281a672633e2e6baa --- /dev/null +++ b/vendor/github.com/olivere/elastic/v7/search_queries_rank_feature.go @@ -0,0 +1,213 @@ +// Copyright 2012-present Oliver Eilhard. All rights reserved. +// Use of this source code is governed by a MIT-license. +// See http://olivere.mit-license.org/license.txt for details. + +package elastic + +// RankFeatureQuery boosts the relevance score of documents based on the +// numeric value of a rank_feature or rank_features field. +// +// The RankFeatureQuery is typically used in the should clause of a BoolQuery +// so its relevance scores are added to other scores from the BoolQuery. +// +// For more details, see: +// https://www.elastic.co/guide/en/elasticsearch/reference/7.14/query-dsl-rank-feature-query.html +type RankFeatureQuery struct { + field string + scoreFunc RankFeatureScoreFunction + boost *float64 + queryName string +} + +// NewRankFeatureQuery creates and initializes a new RankFeatureQuery. +func NewRankFeatureQuery(field string) *RankFeatureQuery { + return &RankFeatureQuery{ + field: field, + } +} + +// Field name. +func (q *RankFeatureQuery) Field(field string) *RankFeatureQuery { + q.field = field + return q +} + +// ScoreFunction specifies the score function for the RankFeatureQuery. +func (q *RankFeatureQuery) ScoreFunction(f RankFeatureScoreFunction) *RankFeatureQuery { + q.scoreFunc = f + return q +} + +// Boost sets the boost for this query. +func (q *RankFeatureQuery) Boost(boost float64) *RankFeatureQuery { + q.boost = &boost + return q +} + +// QueryName sets the query name for the filter that can be used when +// searching for matched_filters per hit. +func (q *RankFeatureQuery) QueryName(queryName string) *RankFeatureQuery { + q.queryName = queryName + return q +} + +// Source returns the JSON serializable content for this query. +func (q *RankFeatureQuery) Source() (interface{}, error) { + // { + // "rank_feature": { + // "field": "pagerank", + // "saturation": { + // "pivot": 8 + // } + // } + // } + + query := make(map[string]interface{}) + params := make(map[string]interface{}) + query["rank_feature"] = params + params["field"] = q.field + if q.scoreFunc != nil { + src, err := q.scoreFunc.Source() + if err != nil { + return nil, err + } + params[q.scoreFunc.Name()] = src + } + if q.boost != nil { + params["boost"] = *q.boost + } + if q.queryName != "" { + params["_name"] = q.queryName + } + + return query, nil +} + +// -- Score functions -- + +// RankFeatureScoreFunction specifies the interface for score functions +// in the context of a RankFeatureQuery. +type RankFeatureScoreFunction interface { + Name() string + Source() (interface{}, error) +} + +// -- Log score function -- + +// RankFeatureLogScoreFunction represents a Logarithmic score function for a +// RankFeatureQuery. +// +// See here for details: +// https://www.elastic.co/guide/en/elasticsearch/reference/7.14/query-dsl-rank-feature-query.html#rank-feature-query-logarithm +type RankFeatureLogScoreFunction struct { + scalingFactor float64 +} + +// NewRankFeatureLogScoreFunction returns a new RankFeatureLogScoreFunction +// with the given scaling factor. +func NewRankFeatureLogScoreFunction(scalingFactor float64) *RankFeatureLogScoreFunction { + return &RankFeatureLogScoreFunction{ + scalingFactor: scalingFactor, + } +} + +// Name of the score function. +func (f *RankFeatureLogScoreFunction) Name() string { return "log" } + +// Source returns a serializable JSON object for building the query. +func (f *RankFeatureLogScoreFunction) Source() (interface{}, error) { + return map[string]interface{}{ + "scaling_factor": f.scalingFactor, + }, nil +} + +// -- Saturation score function -- + +// RankFeatureSaturationScoreFunction represents a Log score function for a +// RankFeatureQuery. +// +// See here for details: +// https://www.elastic.co/guide/en/elasticsearch/reference/7.14/query-dsl-rank-feature-query.html#rank-feature-query-saturation +type RankFeatureSaturationScoreFunction struct { + pivot *float64 +} + +// NewRankFeatureSaturationScoreFunction initializes a new +// RankFeatureSaturationScoreFunction. +func NewRankFeatureSaturationScoreFunction() *RankFeatureSaturationScoreFunction { + return &RankFeatureSaturationScoreFunction{} +} + +// Pivot specifies the pivot to use. +func (f *RankFeatureSaturationScoreFunction) Pivot(pivot float64) *RankFeatureSaturationScoreFunction { + f.pivot = &pivot + return f +} + +// Name of the score function. +func (f *RankFeatureSaturationScoreFunction) Name() string { return "saturation" } + +// Source returns a serializable JSON object for building the query. +func (f *RankFeatureSaturationScoreFunction) Source() (interface{}, error) { + m := make(map[string]interface{}) + if f.pivot != nil { + m["pivot"] = *f.pivot + } + return m, nil +} + +// -- Sigmoid score function -- + +// RankFeatureSigmoidScoreFunction represents a Sigmoid score function for a +// RankFeatureQuery. +// +// See here for details: +// https://www.elastic.co/guide/en/elasticsearch/reference/7.14/query-dsl-rank-feature-query.html#rank-feature-query-sigmoid +type RankFeatureSigmoidScoreFunction struct { + pivot float64 + exponent float64 +} + +// NewRankFeatureSigmoidScoreFunction returns a new RankFeatureSigmoidScoreFunction +// with the given scaling factor. +func NewRankFeatureSigmoidScoreFunction(pivot, exponent float64) *RankFeatureSigmoidScoreFunction { + return &RankFeatureSigmoidScoreFunction{ + pivot: pivot, + exponent: exponent, + } +} + +// Name of the score function. +func (f *RankFeatureSigmoidScoreFunction) Name() string { return "sigmoid" } + +// Source returns a serializable JSON object for building the query. +func (f *RankFeatureSigmoidScoreFunction) Source() (interface{}, error) { + return map[string]interface{}{ + "pivot": f.pivot, + "exponent": f.exponent, + }, nil +} + +// -- Linear score function -- + +// RankFeatureLinearScoreFunction represents a Linear score function for a +// RankFeatureQuery. +// +// See here for details: +// https://www.elastic.co/guide/en/elasticsearch/reference/7.14/query-dsl-rank-feature-query.html#rank-feature-query-linear +type RankFeatureLinearScoreFunction struct { +} + +// NewRankFeatureLinearScoreFunction initializes a new +// RankFeatureLinearScoreFunction. +func NewRankFeatureLinearScoreFunction() *RankFeatureLinearScoreFunction { + return &RankFeatureLinearScoreFunction{} +} + +// Name of the score function. +func (f *RankFeatureLinearScoreFunction) Name() string { return "linear" } + +// Source returns a serializable JSON object for building the query. +func (f *RankFeatureLinearScoreFunction) Source() (interface{}, error) { + return map[string]interface{}{}, nil +} diff --git a/vendor/github.com/olivere/elastic/v7/search_source.go b/vendor/github.com/olivere/elastic/v7/search_source.go index 7578af5b2fcd8c2c1b23e74c323f8a4346942a9a..1113414e42fe90f53effa5d7ff6e67e7630d41ce 100644 --- a/vendor/github.com/olivere/elastic/v7/search_source.go +++ b/vendor/github.com/olivere/elastic/v7/search_source.go @@ -5,6 +5,7 @@ package elastic import ( + "encoding/json" "fmt" ) @@ -42,7 +43,8 @@ type SearchSource struct { collapse *CollapseBuilder // collapse profile bool // profile // TODO extBuilders []SearchExtBuilder // ext - pointInTime *PointInTime // pit + pointInTime *PointInTime // pit + runtimeMappings RuntimeMappings } // NewSearchSource initializes a new SearchSource. @@ -375,6 +377,12 @@ func (s *SearchSource) PointInTime(pointInTime *PointInTime) *SearchSource { return s } +// RuntimeMappings specifies optional runtime mappings. +func (s *SearchSource) RuntimeMappings(runtimeMappings RuntimeMappings) *SearchSource { + s.runtimeMappings = runtimeMappings + return s +} + // Source returns the serializable JSON for the source builder. func (s *SearchSource) Source() (interface{}, error) { source := make(map[string]interface{}) @@ -614,9 +622,29 @@ func (s *SearchSource) Source() (interface{}, error) { source["pit"] = src } + if s.runtimeMappings != nil { + src, err := s.runtimeMappings.Source() + if err != nil { + return nil, err + } + source["runtime_mappings"] = src + } + return source, nil } +// MarshalJSON enables serializing the type as JSON. +func (q *SearchSource) MarshalJSON() ([]byte, error) { + if q == nil { + return nilByte, nil + } + src, err := q.Source() + if err != nil { + return nil, err + } + return json.Marshal(src) +} + // -- IndexBoosts -- // IndexBoost specifies an index by some boost factor. diff --git a/vendor/github.com/olivere/elastic/v7/sort.go b/vendor/github.com/olivere/elastic/v7/sort.go index 60cc0a11f721f833cfc5fcb1f7e2bbdff5c0885b..cd5615b100fe333cce1002575bb45e2b8b4a7619 100644 --- a/vendor/github.com/olivere/elastic/v7/sort.go +++ b/vendor/github.com/olivere/elastic/v7/sort.go @@ -308,16 +308,17 @@ func (s *FieldSort) Source() (interface{}, error) { // See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/search-request-sort.html#_geo_distance_sorting. type GeoDistanceSort struct { Sorter - fieldName string - points []*GeoPoint - geohashes []string - distanceType *string - unit string - ascending bool - sortMode *string - nestedFilter Query - nestedPath *string - nestedSort *NestedSort + fieldName string + points []*GeoPoint + geohashes []string + distanceType *string + unit string + ignoreUnmapped *bool + ascending bool + sortMode *string + nestedFilter Query + nestedPath *string + nestedSort *NestedSort } // NewGeoDistanceSort creates a new sorter for geo distances. @@ -378,6 +379,15 @@ func (s *GeoDistanceSort) Unit(unit string) *GeoDistanceSort { return s } +// IgnoreUnmapped indicates whether the unmapped field should be treated as +// a missing value. Setting it to true is equivalent to specifying an +// unmapped_type in the field sort. The default is false (unmapped field +// causes the search to fail). +func (s *GeoDistanceSort) IgnoreUnmapped(ignoreUnmapped bool) *GeoDistanceSort { + s.ignoreUnmapped = &ignoreUnmapped + return s +} + // GeoDistance is an alias for DistanceType. func (s *GeoDistanceSort) GeoDistance(geoDistance string) *GeoDistanceSort { return s.DistanceType(geoDistance) @@ -439,6 +449,9 @@ func (s *GeoDistanceSort) Source() (interface{}, error) { if s.unit != "" { x["unit"] = s.unit } + if s.ignoreUnmapped != nil { + x["ignore_unmapped"] = *s.ignoreUnmapped + } if s.distanceType != nil { x["distance_type"] = *s.distanceType } diff --git a/vendor/github.com/olivere/elastic/v7/tasks_list.go b/vendor/github.com/olivere/elastic/v7/tasks_list.go index 09aa6b61399458eebb6cd789cfadea12a6773e73..837c098bcd9d0d3c045784d16e6f9a48a60ca74b 100644 --- a/vendor/github.com/olivere/elastic/v7/tasks_list.go +++ b/vendor/github.com/olivere/elastic/v7/tasks_list.go @@ -263,6 +263,7 @@ type TaskInfo struct { RunningTime string `json:"running_time"` RunningTimeInNanos int64 `json:"running_time_in_nanos"` Cancellable bool `json:"cancellable"` + Cancelled bool `json:"cancelled"` ParentTaskId string `json:"parent_task_id"` // like "YxJnVYjwSBm_AUbzddTajQ:12356" Headers map[string]string `json:"headers"` } diff --git a/vendor/github.com/olivere/elastic/v7/xpack_async_search_submit.go b/vendor/github.com/olivere/elastic/v7/xpack_async_search_submit.go index f2c13b69d09a263d53f4ab57ad2aad774721fc44..11ece6857820adb88efb7e7304bafcc045542c49 100644 --- a/vendor/github.com/olivere/elastic/v7/xpack_async_search_submit.go +++ b/vendor/github.com/olivere/elastic/v7/xpack_async_search_submit.go @@ -453,9 +453,16 @@ func (s *XPackAsyncSearchSubmit) TypedKeys(enabled bool) *XPackAsyncSearchSubmit return s } -// SeqNoPrimaryTerm specifies whether to return sequence number and -// primary term of the last modification of each hit. +// SeqNoPrimaryTerm is an alias for SeqNoAndPrimaryTerm. +// +// Deprecated: Use SeqNoAndPrimaryTerm instead. func (s *XPackAsyncSearchSubmit) SeqNoPrimaryTerm(enabled bool) *XPackAsyncSearchSubmit { + return s.SeqNoAndPrimaryTerm(enabled) +} + +// SeqNoAndPrimaryTerm specifies whether to return sequence number and +// primary term of the last modification of each hit. +func (s *XPackAsyncSearchSubmit) SeqNoAndPrimaryTerm(enabled bool) *XPackAsyncSearchSubmit { s.seqNoPrimaryTerm = &enabled return s } diff --git a/vendor/github.com/olivere/elastic/v7/xpack_ilm_get_lifecycle.go b/vendor/github.com/olivere/elastic/v7/xpack_ilm_get_lifecycle.go index 3a52c36d5db18874db78d2444872b42ca841d597..ae2a3fa11de7cb2e6febdcf30776853895e31426 100644 --- a/vendor/github.com/olivere/elastic/v7/xpack_ilm_get_lifecycle.go +++ b/vendor/github.com/olivere/elastic/v7/xpack_ilm_get_lifecycle.go @@ -187,7 +187,17 @@ func (s *XPackIlmGetLifecycleService) Do(ctx context.Context) (map[string]*XPack // XPackIlmGetLifecycleResponse is the response of XPackIlmGetLifecycleService.Do. type XPackIlmGetLifecycleResponse struct { - Version int `json:"version,omitempty"` - ModifiedDate string `json:"modified_date,omitempty"` // e.g. "2019-10-03T17:43:42.720Z" - Policy map[string]interface{} `json:"policy,omitempty"` + Version int `json:"version,omitempty"` + ModifiedDate string `json:"modified_date,omitempty"` // e.g. "2019-10-03T17:43:42.720Z" + Policy map[string]interface{} `json:"policy,omitempty"` + InUseBy *ClusterMetadataItemUsage `json:"in_use_by,omitempty"` +} + +// ClusterMetadataItemUsage encapsulates the usage of a particular "thing" +// by something else. In Elasticsearch, this is in the +// org.elasticsearch.cluster.metadata package. +type ClusterMetadataItemUsage struct { + Indices []string `json:"indices,omitempty"` + DataStreams []string `json:"data_streams,omitempty"` + ComposableTemplates []string `json:"composable_templates,omitempty"` } diff --git a/vendor/github.com/olivere/elastic/v7/xpack_rollup_delete.go b/vendor/github.com/olivere/elastic/v7/xpack_rollup_delete.go new file mode 100644 index 0000000000000000000000000000000000000000..97178ea0a6b2364254cdd5a89cbf7f1a28ef702a --- /dev/null +++ b/vendor/github.com/olivere/elastic/v7/xpack_rollup_delete.go @@ -0,0 +1,159 @@ +// Copyright 2012-present Oliver Eilhard. All rights reserved. +// Use of this source code is governed by a MIT-license. +// See http://olivere.mit-license.org/license.txt for details. + +package elastic + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/olivere/elastic/v7/uritemplates" +) + +// XPackRollupDeleteService delete a rollup job by its job id. +// See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/rollup-delete-job.html. +type XPackRollupDeleteService struct { + client *Client + + pretty *bool // pretty format the returned JSON response + human *bool // return human readable values for statistics + errorTrace *bool // include the stack trace of returned errors + filterPath []string // list of filters used to reduce the response + headers http.Header // custom request-level HTTP headers + + jobId string +} + +// XPackRollupDeleteService creates a new XPackRollupDeleteService. +func NewXPackRollupDeleteService(client *Client) *XPackRollupDeleteService { + return &XPackRollupDeleteService{ + client: client, + } +} + +// Pretty tells Elasticsearch whether to return a formatted JSON response. +func (s *XPackRollupDeleteService) Pretty(pretty bool) *XPackRollupDeleteService { + s.pretty = &pretty + return s +} + +// Human specifies whether human readable values should be returned in +// the JSON response, e.g. "7.5mb". +func (s *XPackRollupDeleteService) Human(human bool) *XPackRollupDeleteService { + s.human = &human + return s +} + +// ErrorTrace specifies whether to include the stack trace of returned errors. +func (s *XPackRollupDeleteService) ErrorTrace(errorTrace bool) *XPackRollupDeleteService { + s.errorTrace = &errorTrace + return s +} + +// FilterPath specifies a list of filters used to reduce the response. +func (s *XPackRollupDeleteService) FilterPath(filterPath ...string) *XPackRollupDeleteService { + s.filterPath = filterPath + return s +} + +// Header adds a header to the request. +func (s *XPackRollupDeleteService) Header(name string, value string) *XPackRollupDeleteService { + if s.headers == nil { + s.headers = http.Header{} + } + s.headers.Add(name, value) + return s +} + +// Headers specifies the headers of the request. +func (s *XPackRollupDeleteService) Headers(headers http.Header) *XPackRollupDeleteService { + s.headers = headers + return s +} + +// JobId is id of the rollup to delete. +func (s *XPackRollupDeleteService) JobId(jobId string) *XPackRollupDeleteService { + s.jobId = jobId + return s +} + +// buildURL builds the URL for the operation. +func (s *XPackRollupDeleteService) buildURL() (string, url.Values, error) { + // Build URL + path, err := uritemplates.Expand("/_rollup/job/{job_id}", map[string]string{ + "job_id": s.jobId, + }) + if err != nil { + return "", url.Values{}, err + } + + // Add query string parameters + params := url.Values{} + if v := s.pretty; v != nil { + params.Set("pretty", fmt.Sprint(*v)) + } + if v := s.human; v != nil { + params.Set("human", fmt.Sprint(*v)) + } + if v := s.errorTrace; v != nil { + params.Set("error_trace", fmt.Sprint(*v)) + } + if len(s.filterPath) > 0 { + params.Set("filter_path", strings.Join(s.filterPath, ",")) + } + return path, params, nil +} + +// Validate checks if the operation is valid. +func (s *XPackRollupDeleteService) Validate() error { + var invalid []string + if s.jobId == "" { + invalid = append(invalid, "Job ID") + } + if len(invalid) > 0 { + return fmt.Errorf("missing required fields: %v", invalid) + } + return nil +} + +// Do executes the operation. +func (s *XPackRollupDeleteService) Do(ctx context.Context) (*XPackRollupDeleteResponse, error) { + // Check pre-conditions + if err := s.Validate(); err != nil { + return nil, err + } + + // Get URL for request + path, params, err := s.buildURL() + if err != nil { + return nil, err + } + + // Get HTTP response + res, err := s.client.PerformRequest(ctx, PerformRequestOptions{ + Method: "DELETE", + Path: path, + Params: params, + Headers: s.headers, + }) + if err != nil { + return nil, err + } + + // Return operation response + ret := new(XPackRollupDeleteResponse) + if err := json.Unmarshal(res.Body, ret); err != nil { + return nil, err + } + return ret, nil +} + +// XPackRollupDeleteResponse is the response of XPackRollupDeleteService.Do. +type XPackRollupDeleteResponse struct { + Acknowledged bool `json:"acknowledged"` +} diff --git a/vendor/github.com/olivere/elastic/v7/xpack_rollup_get.go b/vendor/github.com/olivere/elastic/v7/xpack_rollup_get.go new file mode 100644 index 0000000000000000000000000000000000000000..8b7e2d78c7473b4504ae9bfb45e62e37765d9a3d --- /dev/null +++ b/vendor/github.com/olivere/elastic/v7/xpack_rollup_get.go @@ -0,0 +1,202 @@ +// Copyright 2012-present Oliver Eilhard. All rights reserved. +// Use of this source code is governed by a MIT-license. +// See http://olivere.mit-license.org/license.txt for details. + +package elastic + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/olivere/elastic/v7/uritemplates" +) + +// XPackRollupGetService retrieves a role by its name. +// See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/rollup-apis.html. +type XPackRollupGetService struct { + client *Client + + pretty *bool // pretty format the returned JSON response + human *bool // return human readable values for statistics + errorTrace *bool // include the stack trace of returned errors + filterPath []string // list of filters used to reduce the response + headers http.Header // custom request-level HTTP headers + + jobId string +} + +// NewXPackRollupGetService creates a new XPackRollupGetService. +func NewXPackRollupGetService(client *Client) *XPackRollupGetService { + return &XPackRollupGetService{ + client: client, + } +} + +// Pretty tells Elasticsearch whether to return a formatted JSON response. +func (s *XPackRollupGetService) Pretty(pretty bool) *XPackRollupGetService { + s.pretty = &pretty + return s +} + +// Human specifies whether human readable values should be returned in +// the JSON response, e.g. "7.5mb". +func (s *XPackRollupGetService) Human(human bool) *XPackRollupGetService { + s.human = &human + return s +} + +// ErrorTrace specifies whether to include the stack trace of returned errors. +func (s *XPackRollupGetService) ErrorTrace(errorTrace bool) *XPackRollupGetService { + s.errorTrace = &errorTrace + return s +} + +// FilterPath specifies a list of filters used to reduce the response. +func (s *XPackRollupGetService) FilterPath(filterPath ...string) *XPackRollupGetService { + s.filterPath = filterPath + return s +} + +// Header adds a header to the request. +func (s *XPackRollupGetService) Header(name string, value string) *XPackRollupGetService { + if s.headers == nil { + s.headers = http.Header{} + } + s.headers.Add(name, value) + return s +} + +// Headers specifies the headers of the request. +func (s *XPackRollupGetService) Headers(headers http.Header) *XPackRollupGetService { + s.headers = headers + return s +} + +// JobId is id of the rollup to retrieve. +func (s *XPackRollupGetService) JobId(jobId string) *XPackRollupGetService { + s.jobId = jobId + return s +} + +// buildURL builds the URL for the operation. +func (s *XPackRollupGetService) buildURL() (string, url.Values, error) { + // Build URL + path, err := uritemplates.Expand("/_rollup/job/{job_id}", map[string]string{ + "job_id": s.jobId, + }) + if err != nil { + return "", url.Values{}, err + } + + // Add query string parameters + params := url.Values{} + if v := s.pretty; v != nil { + params.Set("pretty", fmt.Sprint(*v)) + } + if v := s.human; v != nil { + params.Set("human", fmt.Sprint(*v)) + } + if v := s.errorTrace; v != nil { + params.Set("error_trace", fmt.Sprint(*v)) + } + if len(s.filterPath) > 0 { + params.Set("filter_path", strings.Join(s.filterPath, ",")) + } + return path, params, nil +} + +// Validate checks if the operation is valid. +func (s *XPackRollupGetService) Validate() error { + var invalid []string + if s.jobId == "" { + invalid = append(invalid, "Job ID") + } + if len(invalid) > 0 { + return fmt.Errorf("missing required fields: %v", invalid) + } + return nil +} + +// Do executes the operation. +func (s *XPackRollupGetService) Do(ctx context.Context) (*XPackRollupGetResponse, error) { + // Check pre-conditions + if err := s.Validate(); err != nil { + return nil, err + } + + // Get URL for request + path, params, err := s.buildURL() + if err != nil { + return nil, err + } + + // Get HTTP response + res, err := s.client.PerformRequest(ctx, PerformRequestOptions{ + Method: "GET", + Path: path, + Params: params, + Headers: s.headers, + }) + if err != nil { + return nil, err + } + + // Return operation response + ret := XPackRollupGetResponse{} + if err := json.Unmarshal(res.Body, &ret); err != nil { + return nil, err + } + return &ret, nil +} + +// XPackRollupGetResponse is the response of XPackRollupGetService.Do. +type XPackRollupGetResponse struct { + Jobs []XPackRollup `json:"jobs"` +} + +// XPackRollup is the role object. +type XPackRollup struct { + Config XPackRollupConfig `json:"config"` + Status XPackRollupStatus `json:"status"` + Stats XPackRollupStats `json:"stats"` +} + +type XPackRollupConfig struct { + Id string `json:"id"` + Cron string `json:"cron"` + IndexPattern string `json:"index_pattern"` + RollupIndex string `json:"rollup_index"` + Groups map[string]interface{} `json:"groups"` + Metrics []XPackRollupMetrics `json:"metrics"` + Timeout string `json:"timeout"` + PageSize int `json:"page_size"` +} + +type XPackRollupMetrics struct { + Field string `json:"field"` + Metrics []string `json:"metrics"` +} + +type XPackRollupStatus struct { + JobState string `json:"job_state"` + UpgradedDocId bool `json:"upgraded_doc_id"` +} + +type XPackRollupStats struct { + PageProcessed int `json:"pages_processed"` + DocumentsProcessed int `json:"documents_processed"` + RollupsIndexed int `json:"rollups_indexed"` + TriggerCount int `json:"trigger_count"` + IndexFailures int `json:"index_failures"` + IndexTimeInMs int `json:"index_time_in_ms"` + IndexTotal int `json:"index_total"` + SearchFailures int `json:"search_failures"` + SearchTimeInMs int `json:"search_time_in_ms"` + SearchTotal int `json:"search_total"` + ProcessingTimeInMs int `json:"processing_time_in_ms"` + ProcessingTotal int `json:"processing_total"` +} diff --git a/vendor/github.com/olivere/elastic/v7/xpack_rollup_put.go b/vendor/github.com/olivere/elastic/v7/xpack_rollup_put.go new file mode 100644 index 0000000000000000000000000000000000000000..a2442d4ae839b32c8f2b4843c654aa7b11085308 --- /dev/null +++ b/vendor/github.com/olivere/elastic/v7/xpack_rollup_put.go @@ -0,0 +1,170 @@ +// Copyright 2012-present Oliver Eilhard. All rights reserved. +// Use of this source code is governed by a MIT-license. +// See http://olivere.mit-license.org/license.txt for details. + +package elastic + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/olivere/elastic/v7/uritemplates" +) + +// XPackRollupPutService create or update a rollup job by its job id. +// See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/rollup-put-job.html. +type XPackRollupPutService struct { + client *Client + + pretty *bool // pretty format the returned JSON response + human *bool // return human readable values for statistics + errorTrace *bool // include the stack trace of returned errors + filterPath []string // list of filters used to reduce the response + headers http.Header // custom request-level HTTP headers + + jobId string + body interface{} +} + +// NewXPackRollupPutService creates a new XPackRollupPutService. +func NewXPackRollupPutService(client *Client) *XPackRollupPutService { + return &XPackRollupPutService{ + client: client, + } +} + +// Pretty tells Elasticsearch whether to return a formatted JSON response. +func (s *XPackRollupPutService) Pretty(pretty bool) *XPackRollupPutService { + s.pretty = &pretty + return s +} + +// Human specifies whether human readable values should be returned in +// the JSON response, e.g. "7.5mb". +func (s *XPackRollupPutService) Human(human bool) *XPackRollupPutService { + s.human = &human + return s +} + +// ErrorTrace specifies whether to include the stack trace of returned errors. +func (s *XPackRollupPutService) ErrorTrace(errorTrace bool) *XPackRollupPutService { + s.errorTrace = &errorTrace + return s +} + +// FilterPath specifies a list of filters used to reduce the response. +func (s *XPackRollupPutService) FilterPath(filterPath ...string) *XPackRollupPutService { + s.filterPath = filterPath + return s +} + +// Header adds a header to the request. +func (s *XPackRollupPutService) Header(name string, value string) *XPackRollupPutService { + if s.headers == nil { + s.headers = http.Header{} + } + s.headers.Add(name, value) + return s +} + +// Headers specifies the headers of the request. +func (s *XPackRollupPutService) Headers(headers http.Header) *XPackRollupPutService { + s.headers = headers + return s +} + +// JobId is id of the rollup to create. +func (s *XPackRollupPutService) JobId(jobId string) *XPackRollupPutService { + s.jobId = jobId + return s +} + +// Body specifies the role. Use a string or a type that will get serialized as JSON. +func (s *XPackRollupPutService) Body(body interface{}) *XPackRollupPutService { + s.body = body + return s +} + +// buildURL builds the URL for the operation. +func (s *XPackRollupPutService) buildURL() (string, url.Values, error) { + // Build URL + path, err := uritemplates.Expand("/_rollup/job/{job_id}", map[string]string{ + "job_id": s.jobId, + }) + if err != nil { + return "", url.Values{}, err + } + + // Add query string parameters + params := url.Values{} + if v := s.pretty; v != nil { + params.Set("pretty", fmt.Sprint(*v)) + } + if v := s.human; v != nil { + params.Set("human", fmt.Sprint(*v)) + } + if v := s.errorTrace; v != nil { + params.Set("error_trace", fmt.Sprint(*v)) + } + if len(s.filterPath) > 0 { + params.Set("filter_path", strings.Join(s.filterPath, ",")) + } + return path, params, nil +} + +// Validate checks if the operation is valid. +func (s *XPackRollupPutService) Validate() error { + var invalid []string + if s.jobId == "" { + invalid = append(invalid, "Job ID") + } + if s.body == nil { + invalid = append(invalid, "Body") + } + if len(invalid) > 0 { + return fmt.Errorf("missing required fields: %v", invalid) + } + return nil +} + +// Do executes the operation. +func (s *XPackRollupPutService) Do(ctx context.Context) (*XPackRollupPutResponse, error) { + // Check pre-conditions + if err := s.Validate(); err != nil { + return nil, err + } + + // Get URL for request + path, params, err := s.buildURL() + if err != nil { + return nil, err + } + + // Get HTTP response + res, err := s.client.PerformRequest(ctx, PerformRequestOptions{ + Method: "PUT", + Path: path, + Params: params, + Body: s.body, + Headers: s.headers, + }) + if err != nil { + return nil, err + } + + // Return operation response + ret := new(XPackRollupPutResponse) + if err := json.Unmarshal(res.Body, ret); err != nil { + return nil, err + } + return ret, nil +} + +// XPackRollupPutResponse is the response of XPackRollupPutService.Do. +type XPackRollupPutResponse struct { + Acknowledged bool `json:"acknowledged"` +} diff --git a/vendor/github.com/olivere/elastic/v7/xpack_rollup_start.go b/vendor/github.com/olivere/elastic/v7/xpack_rollup_start.go new file mode 100644 index 0000000000000000000000000000000000000000..0f43e9157afc6297654d228a132f8f1977196cf2 --- /dev/null +++ b/vendor/github.com/olivere/elastic/v7/xpack_rollup_start.go @@ -0,0 +1,159 @@ +// Copyright 2012-present Oliver Eilhard. All rights reserved. +// Use of this source code is governed by a MIT-license. +// See http://olivere.mit-license.org/license.txt for details. + +package elastic + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/olivere/elastic/v7/uritemplates" +) + +// XPackRollupStartService starts the rollup job if it is not already running. +// See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/rollup-start-job.html. +type XPackRollupStartService struct { + client *Client + + pretty *bool // pretty format the returned JSON response + human *bool // return human readable values for statistics + errorTrace *bool // include the stack trace of returned errors + filterPath []string // list of filters used to reduce the response + headers http.Header // custom request-level HTTP headers + + jobId string +} + +// NewXPackRollupStartService creates a new XPackRollupStartService. +func NewXPackRollupStartService(client *Client) *XPackRollupStartService { + return &XPackRollupStartService{ + client: client, + } +} + +// Pretty tells Elasticsearch whether to return a formatted JSON response. +func (s *XPackRollupStartService) Pretty(pretty bool) *XPackRollupStartService { + s.pretty = &pretty + return s +} + +// Human specifies whether human readable values should be returned in +// the JSON response, e.g. "7.5mb". +func (s *XPackRollupStartService) Human(human bool) *XPackRollupStartService { + s.human = &human + return s +} + +// ErrorTrace specifies whether to include the stack trace of returned errors. +func (s *XPackRollupStartService) ErrorTrace(errorTrace bool) *XPackRollupStartService { + s.errorTrace = &errorTrace + return s +} + +// FilterPath specifies a list of filters used to reduce the response. +func (s *XPackRollupStartService) FilterPath(filterPath ...string) *XPackRollupStartService { + s.filterPath = filterPath + return s +} + +// Header adds a header to the request. +func (s *XPackRollupStartService) Header(name string, value string) *XPackRollupStartService { + if s.headers == nil { + s.headers = http.Header{} + } + s.headers.Add(name, value) + return s +} + +// Headers specifies the headers of the request. +func (s *XPackRollupStartService) Headers(headers http.Header) *XPackRollupStartService { + s.headers = headers + return s +} + +// JobId is id of the rollup to retrieve. +func (s *XPackRollupStartService) JobId(jobId string) *XPackRollupStartService { + s.jobId = jobId + return s +} + +// buildURL builds the URL for the operation. +func (s *XPackRollupStartService) buildURL() (string, url.Values, error) { + // Build URL path + path, err := uritemplates.Expand("/_rollup/job/{job_id}/_start", map[string]string{ + "job_id": s.jobId, + }) + if err != nil { + return "", url.Values{}, err + } + + // Add query string parameters + params := url.Values{} + if v := s.pretty; v != nil { + params.Set("pretty", fmt.Sprint(*v)) + } + if v := s.human; v != nil { + params.Set("human", fmt.Sprint(*v)) + } + if v := s.errorTrace; v != nil { + params.Set("error_trace", fmt.Sprint(*v)) + } + if len(s.filterPath) > 0 { + params.Set("filter_path", strings.Join(s.filterPath, ",")) + } + return path, params, nil +} + +// Validate checks if the operation is valid. +func (s *XPackRollupStartService) Validate() error { + var invalid []string + if s.jobId == "" { + invalid = append(invalid, "Job ID") + } + if len(invalid) > 0 { + return fmt.Errorf("missing required fields: %v", invalid) + } + return nil +} + +// Do executes the operation. +func (s *XPackRollupStartService) Do(ctx context.Context) (*XPackRollupStartResponse, error) { + // Check pre-conditions + if err := s.Validate(); err != nil { + return nil, err + } + + // Get URL for request + path, params, err := s.buildURL() + if err != nil { + return nil, err + } + + // Get HTTP response + res, err := s.client.PerformRequest(ctx, PerformRequestOptions{ + Method: "POST", + Path: path, + Params: params, + Headers: s.headers, + }) + if err != nil { + return nil, err + } + + // Return operation response + ret := new(XPackRollupStartResponse) + if err := json.Unmarshal(res.Body, ret); err != nil { + return nil, err + } + return ret, nil +} + +// XPackRollupStartResponse is the response of XPackRollupStartService.Do. +type XPackRollupStartResponse struct { + Started bool `json:"started"` +} diff --git a/vendor/github.com/olivere/elastic/v7/xpack_rollup_stop.go b/vendor/github.com/olivere/elastic/v7/xpack_rollup_stop.go new file mode 100644 index 0000000000000000000000000000000000000000..4d984acb21dafa1f6a40a050bed75d85396baf6c --- /dev/null +++ b/vendor/github.com/olivere/elastic/v7/xpack_rollup_stop.go @@ -0,0 +1,159 @@ +// Copyright 2012-present Oliver Eilhard. All rights reserved. +// Use of this source code is governed by a MIT-license. +// See http://olivere.mit-license.org/license.txt for details. + +package elastic + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/olivere/elastic/v7/uritemplates" +) + +// XPackRollupStartService stops the rollup job if it is running. +// See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/rollup-stop-job.html. +type XPackRollupStopService struct { + client *Client + + pretty *bool // pretty format the returned JSON response + human *bool // return human readable values for statistics + errorTrace *bool // include the stack trace of returned errors + filterPath []string // list of filters used to reduce the response + headers http.Header // custom request-level HTTP headers + + jobId string +} + +// NewXPackRollupStopService creates a new XPackRollupStopService. +func NewXPackRollupStopService(client *Client) *XPackRollupStopService { + return &XPackRollupStopService{ + client: client, + } +} + +// Pretty tells Elasticsearch whether to return a formatted JSON response. +func (s *XPackRollupStopService) Pretty(pretty bool) *XPackRollupStopService { + s.pretty = &pretty + return s +} + +// Human specifies whether human readable values should be returned in +// the JSON response, e.g. "7.5mb". +func (s *XPackRollupStopService) Human(human bool) *XPackRollupStopService { + s.human = &human + return s +} + +// ErrorTrace specifies whether to include the stack trace of returned errors. +func (s *XPackRollupStopService) ErrorTrace(errorTrace bool) *XPackRollupStopService { + s.errorTrace = &errorTrace + return s +} + +// FilterPath specifies a list of filters used to reduce the response. +func (s *XPackRollupStopService) FilterPath(filterPath ...string) *XPackRollupStopService { + s.filterPath = filterPath + return s +} + +// Header adds a header to the request. +func (s *XPackRollupStopService) Header(name string, value string) *XPackRollupStopService { + if s.headers == nil { + s.headers = http.Header{} + } + s.headers.Add(name, value) + return s +} + +// Headers specifies the headers of the request. +func (s *XPackRollupStopService) Headers(headers http.Header) *XPackRollupStopService { + s.headers = headers + return s +} + +// JobId is id of the rollup to retrieve. +func (s *XPackRollupStopService) JobId(jobId string) *XPackRollupStopService { + s.jobId = jobId + return s +} + +// buildURL builds the URL for the operation. +func (s *XPackRollupStopService) buildURL() (string, url.Values, error) { + // Build URL path + path, err := uritemplates.Expand("/_rollup/job/{job_id}/_stop", map[string]string{ + "job_id": s.jobId, + }) + if err != nil { + return "", url.Values{}, err + } + + // Add query string parameters + params := url.Values{} + if v := s.pretty; v != nil { + params.Set("pretty", fmt.Sprint(*v)) + } + if v := s.human; v != nil { + params.Set("human", fmt.Sprint(*v)) + } + if v := s.errorTrace; v != nil { + params.Set("error_trace", fmt.Sprint(*v)) + } + if len(s.filterPath) > 0 { + params.Set("filter_path", strings.Join(s.filterPath, ",")) + } + return path, params, nil +} + +// Validate checks if the operation is valid. +func (s *XPackRollupStopService) Validate() error { + var invalid []string + if s.jobId == "" { + invalid = append(invalid, "Job ID") + } + if len(invalid) > 0 { + return fmt.Errorf("missing required fields: %v", invalid) + } + return nil +} + +// Do executes the operation. +func (s *XPackRollupStopService) Do(ctx context.Context) (*XPackRollupStopResponse, error) { + // Check pre-conditions + if err := s.Validate(); err != nil { + return nil, err + } + + // Get URL for request + path, params, err := s.buildURL() + if err != nil { + return nil, err + } + + // Get HTTP response + res, err := s.client.PerformRequest(ctx, PerformRequestOptions{ + Method: "POST", + Path: path, + Params: params, + Headers: s.headers, + }) + if err != nil { + return nil, err + } + + // Return operation response + ret := new(XPackRollupStopResponse) + if err := json.Unmarshal(res.Body, ret); err != nil { + return nil, err + } + return ret, nil +} + +// XPackRollupStopResponse is the response of XPackRollupStopService.Do. +type XPackRollupStopResponse struct { + Stoppeed bool `json:"stopped"` +} diff --git a/vendor/modules.txt b/vendor/modules.txt index b081b971881c06b4cd0c88866b4e7f2bb32ec4cf..dc2e103681be066ac474cba18d2c073417572588 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -5,7 +5,7 @@ github.com/mailru/easyjson github.com/mailru/easyjson/buffer github.com/mailru/easyjson/jlexer github.com/mailru/easyjson/jwriter -# github.com/olivere/elastic/v7 v7.0.26 +# github.com/olivere/elastic/v7 v7.0.32 github.com/olivere/elastic/v7 github.com/olivere/elastic/v7/config github.com/olivere/elastic/v7/uritemplates