summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/olivere/elastic
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-07-04 04:06:10 +0200
committerGitHub <noreply@github.com>2021-07-04 04:06:10 +0200
commitfae07cbc8fece383c88ed7b13474a94133c4accf (patch)
tree65e3279dc5655d22302c9b79c48ecd3d1a06ffcd /vendor/github.com/olivere/elastic
parent65ae46bc20f60534ba2590a106a6c86aaa1ecae0 (diff)
downloadgitea-fae07cbc8fece383c88ed7b13474a94133c4accf.tar.gz
gitea-fae07cbc8fece383c88ed7b13474a94133c4accf.zip
Update Vendor (#16325)
* Add Dependencie Update Script * update gitea.com/lunny/levelqueue * update github.com/PuerkitoBio/goquery * update github.com/alecthomas/chroma * update github.com/blevesearch/bleve/v2 * update github.com/caddyserver/certmagic * update github.com/go-enry/go-enry/v2 * update github.com/go-redis/redis/v8 * update github.com/hashicorp/golang-lru * update github.com/klauspost/compress * update github.com/markbates/goth * update github.com/mholt/archiver/v3 * update github.com/microcosm-cc/bluemonday * update github.com/minio/minio-go/v7 * update github.com/olivere/elastic/v7 * update github.com/xanzy/go-gitlab * update github.com/yuin/goldmark
Diffstat (limited to 'vendor/github.com/olivere/elastic')
-rw-r--r--vendor/github.com/olivere/elastic/v7/CONTRIBUTORS2
-rw-r--r--vendor/github.com/olivere/elastic/v7/README.md3
-rw-r--r--vendor/github.com/olivere/elastic/v7/client.go28
-rw-r--r--vendor/github.com/olivere/elastic/v7/docker-compose.yml5
-rw-r--r--vendor/github.com/olivere/elastic/v7/errors.go26
-rw-r--r--vendor/github.com/olivere/elastic/v7/go.mod3
-rw-r--r--vendor/github.com/olivere/elastic/v7/indices_delete.go38
-rw-r--r--vendor/github.com/olivere/elastic/v7/indices_delete_component_template.go182
-rw-r--r--vendor/github.com/olivere/elastic/v7/indices_get_component_template.go207
-rw-r--r--vendor/github.com/olivere/elastic/v7/indices_put_component_template.go221
-rw-r--r--vendor/github.com/olivere/elastic/v7/search.go2
-rw-r--r--vendor/github.com/olivere/elastic/v7/search_aggs.go109
-rw-r--r--vendor/github.com/olivere/elastic/v7/search_aggs_bucket_multi_terms.go316
-rw-r--r--vendor/github.com/olivere/elastic/v7/search_aggs_metrics_top_metrics.go83
-rw-r--r--vendor/github.com/olivere/elastic/v7/search_queries_match_bool_prefix.go130
-rw-r--r--vendor/github.com/olivere/elastic/v7/search_queries_prefix.go19
-rw-r--r--vendor/github.com/olivere/elastic/v7/search_queries_regexp.go9
-rw-r--r--vendor/github.com/olivere/elastic/v7/search_queries_term.go19
-rw-r--r--vendor/github.com/olivere/elastic/v7/search_queries_wildcard.go8
-rw-r--r--vendor/github.com/olivere/elastic/v7/tasks_list.go5
20 files changed, 1370 insertions, 45 deletions
diff --git a/vendor/github.com/olivere/elastic/v7/CONTRIBUTORS b/vendor/github.com/olivere/elastic/v7/CONTRIBUTORS
index 32912ebdd3..b3d265c1de 100644
--- a/vendor/github.com/olivere/elastic/v7/CONTRIBUTORS
+++ b/vendor/github.com/olivere/elastic/v7/CONTRIBUTORS
@@ -32,6 +32,7 @@ arthurgustin [@arthurgustin](https://github.com/arthurgustin)
Bas van Dijk [@basvandijk](https://github.com/basvandijk)
Benjamin Fernandes [@LotharSee](https://github.com/LotharSee)
Benjamin Zarzycki [@kf6nux](https://github.com/kf6nux)
+bestgopher [@bestgopher](https://github.com/bestgopher)
Björn Gerdau [@kernle32dll](https://github.com/kernle32dll)
Boris Popovschi [@Zyqsempai](https://github.com/Zyqsempai)
Bowei Xu [@vancexu](https://github.com/vancexu)
@@ -148,6 +149,7 @@ mmfrb [@mmfrb](https://github.com/mmfrb)
mnpritula [@mnpritula](https://github.com/mnpritula)
mosa [@mosasiru](https://github.com/mosasiru)
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)
diff --git a/vendor/github.com/olivere/elastic/v7/README.md b/vendor/github.com/olivere/elastic/v7/README.md
index ac43f557fa..ee547761b6 100644
--- a/vendor/github.com/olivere/elastic/v7/README.md
+++ b/vendor/github.com/olivere/elastic/v7/README.md
@@ -196,7 +196,7 @@ Here are a few tips on how to get used to Elastic:
- [x] Sum
- [ ] T-test (X-pack)
- [x] Top Hits
- - [ ] Top metrics (X-pack)
+ - [x] Top metrics (X-pack)
- [x] Value Count
- [x] Weighted avg
- Bucket Aggregations
@@ -333,6 +333,7 @@ Here are a few tips on how to get used to Elastic:
- [x] Inner hits
- Full text queries
- [x] Match Query
+ - [x] Match Boolean Prefix Query
- [x] Match Phrase Query
- [x] Match Phrase Prefix Query
- [x] Multi Match Query
diff --git a/vendor/github.com/olivere/elastic/v7/client.go b/vendor/github.com/olivere/elastic/v7/client.go
index ad351a4632..856dd1d814 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.24"
+ Version = "7.0.25"
// 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.
@@ -1842,7 +1842,31 @@ func (c *Client) IndexDeleteIndexTemplate(name string) *IndicesDeleteIndexTempla
return NewIndicesDeleteIndexTemplateService(c).Name(name)
}
-// -- TODO Component templates --
+// -- Component templates --
+
+// IndexPutComponentTemplate creates or updates a component template (available since 7.8).
+//
+// This service implements the component templates as described
+// on https://www.elastic.co/guide/en/elasticsearch/reference/7.10/indices-component-template.html.
+func (c *Client) IndexPutComponentTemplate(name string) *IndicesPutComponentTemplateService {
+ return NewIndicesPutComponentTemplateService(c).Name(name)
+}
+
+// IndexGetComponentTemplate returns a component template (available since 7.8).
+//
+// This service implements the component templates as described
+// on https://www.elastic.co/guide/en/elasticsearch/reference/7.10/getting-component-templates.html.
+func (c *Client) IndexGetComponentTemplate(name string) *IndicesGetComponentTemplateService {
+ return NewIndicesGetComponentTemplateService(c).Name(name)
+}
+
+// IndexDeleteComponentTemplate deletes a component template (available since 7.8).
+//
+// This service implements the component templates as described
+// on https://www.elastic.co/guide/en/elasticsearch/reference/7.10/indices-delete-component-template.html.
+func (c *Client) IndexDeleteComponentTemplate(name string) *IndicesDeleteComponentTemplateService {
+ return NewIndicesDeleteComponentTemplateService(c).Name(name)
+}
// GetMapping gets a mapping.
func (c *Client) GetMapping() *IndicesGetMappingService {
diff --git a/vendor/github.com/olivere/elastic/v7/docker-compose.yml b/vendor/github.com/olivere/elastic/v7/docker-compose.yml
index aca2553a6a..4b8761cffb 100644
--- a/vendor/github.com/olivere/elastic/v7/docker-compose.yml
+++ b/vendor/github.com/olivere/elastic/v7/docker-compose.yml
@@ -2,7 +2,7 @@ version: '3'
services:
elasticsearch:
- image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
+ image: docker.elastic.co/elasticsearch/elasticsearch:7.13.2
hostname: elasticsearch
environment:
- cluster.name=elasticsearch
@@ -14,6 +14,7 @@ services:
# - network.host=_local_
- network.publish_host=127.0.0.1
- logger.org.elasticsearch=warn
+ - xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
ulimits:
nproc: 65536
@@ -28,7 +29,7 @@ services:
ports:
- 9200:9200
platinum:
- image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
+ image: docker.elastic.co/elasticsearch/elasticsearch:7.13.2
hostname: elasticsearch-platinum
environment:
- cluster.name=platinum
diff --git a/vendor/github.com/olivere/elastic/v7/errors.go b/vendor/github.com/olivere/elastic/v7/errors.go
index ee11f0b3f3..c17c5ed549 100644
--- a/vendor/github.com/olivere/elastic/v7/errors.go
+++ b/vendor/github.com/olivere/elastic/v7/errors.go
@@ -204,19 +204,15 @@ func IsStatusCode(err interface{}, code int) bool {
// ShardsInfo represents information from a shard.
type ShardsInfo struct {
- Total int `json:"total"`
- Successful int `json:"successful"`
- Failed int `json:"failed"`
- Failures []*ShardFailure `json:"failures,omitempty"`
- Skipped int `json:"skipped,omitempty"`
-}
-
-// ShardFailure represents details about a failure.
-type ShardFailure struct {
- Index string `json:"_index,omitempty"`
- Shard int `json:"_shard,omitempty"`
- Node string `json:"_node,omitempty"`
- Reason map[string]interface{} `json:"reason,omitempty"`
- Status string `json:"status,omitempty"`
- Primary bool `json:"primary,omitempty"`
+ Total int `json:"total"`
+ Successful int `json:"successful"`
+ Failed int `json:"failed"`
+ Failures []*FailedNodeException `json:"failures,omitempty"`
+ Skipped int `json:"skipped,omitempty"`
+}
+
+// FailedNodeException returns an error on the node level.
+type FailedNodeException struct {
+ *ErrorDetails
+ NodeId string `json:"node_id"`
}
diff --git a/vendor/github.com/olivere/elastic/v7/go.mod b/vendor/github.com/olivere/elastic/v7/go.mod
index 00c6cc1af0..e82873f4d1 100644
--- a/vendor/github.com/olivere/elastic/v7/go.mod
+++ b/vendor/github.com/olivere/elastic/v7/go.mod
@@ -3,9 +3,8 @@ module github.com/olivere/elastic/v7
go 1.14
require (
- github.com/aws/aws-sdk-go v1.38.3
+ github.com/aws/aws-sdk-go v1.38.17
github.com/fortytw2/leaktest v1.3.0
- github.com/go-sql-driver/mysql v1.5.0 // indirect
github.com/google/go-cmp v0.5.5
github.com/mailru/easyjson v0.7.7
github.com/opentracing/opentracing-go v1.2.0
diff --git a/vendor/github.com/olivere/elastic/v7/indices_delete.go b/vendor/github.com/olivere/elastic/v7/indices_delete.go
index cdf27a5606..e89b2f8f3a 100644
--- a/vendor/github.com/olivere/elastic/v7/indices_delete.go
+++ b/vendor/github.com/olivere/elastic/v7/indices_delete.go
@@ -27,9 +27,12 @@ type IndicesDeleteService 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
+ index []string
+ timeout string
+ masterTimeout string
+ ignoreUnavailable *bool
+ allowNoIndices *bool
+ expandWildcards string
}
// NewIndicesDeleteService creates and initializes a new IndicesDeleteService.
@@ -99,6 +102,26 @@ func (s *IndicesDeleteService) MasterTimeout(masterTimeout string) *IndicesDelet
return s
}
+// IgnoreUnavailable indicates whether to ignore unavailable indexes (default: false).
+func (s *IndicesDeleteService) IgnoreUnavailable(ignoreUnavailable bool) *IndicesDeleteService {
+ s.ignoreUnavailable = &ignoreUnavailable
+ return s
+}
+
+// AllowNoIndices indicates whether to ignore if a wildcard expression
+// resolves to no concrete indices (default: false).
+func (s *IndicesDeleteService) AllowNoIndices(allowNoIndices bool) *IndicesDeleteService {
+ s.allowNoIndices = &allowNoIndices
+ return s
+}
+
+// ExpandWildcards indicates whether wildcard expressions should get
+// expanded to open or closed indices (default: open).
+func (s *IndicesDeleteService) ExpandWildcards(expandWildcards string) *IndicesDeleteService {
+ s.expandWildcards = expandWildcards
+ return s
+}
+
// buildURL builds the URL for the operation.
func (s *IndicesDeleteService) buildURL() (string, url.Values, error) {
// Build URL
@@ -129,6 +152,15 @@ func (s *IndicesDeleteService) buildURL() (string, url.Values, error) {
if s.masterTimeout != "" {
params.Set("master_timeout", s.masterTimeout)
}
+ if s.ignoreUnavailable != nil {
+ params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
+ }
+ if s.allowNoIndices != nil {
+ params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
+ }
+ if s.expandWildcards != "" {
+ params.Set("expand_wildcards", s.expandWildcards)
+ }
return path, params, nil
}
diff --git a/vendor/github.com/olivere/elastic/v7/indices_delete_component_template.go b/vendor/github.com/olivere/elastic/v7/indices_delete_component_template.go
new file mode 100644
index 0000000000..46b842ab96
--- /dev/null
+++ b/vendor/github.com/olivere/elastic/v7/indices_delete_component_template.go
@@ -0,0 +1,182 @@
+// 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"
+)
+
+// IndicesDeleteComponentTemplateService deletes component templates.
+//
+// See https://www.elastic.co/guide/en/elasticsearch/reference/7.10/indices-delete-component-template.html
+// for more details.
+type IndicesDeleteComponentTemplateService 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
+
+ name string
+ timeout string
+ masterTimeout string
+}
+
+// NewIndicesDeleteComponentTemplateService creates a new IndicesDeleteComponentTemplateService.
+func NewIndicesDeleteComponentTemplateService(client *Client) *IndicesDeleteComponentTemplateService {
+ return &IndicesDeleteComponentTemplateService{
+ client: client,
+ }
+}
+
+// Pretty tells Elasticsearch whether to return a formatted JSON response.
+func (s *IndicesDeleteComponentTemplateService) Pretty(pretty bool) *IndicesDeleteComponentTemplateService {
+ s.pretty = &pretty
+ return s
+}
+
+// Human specifies whether human readable values should be returned in
+// the JSON response, e.g. "7.5mb".
+func (s *IndicesDeleteComponentTemplateService) Human(human bool) *IndicesDeleteComponentTemplateService {
+ s.human = &human
+ return s
+}
+
+// ErrorTrace specifies whether to include the stack trace of returned errors.
+func (s *IndicesDeleteComponentTemplateService) ErrorTrace(errorTrace bool) *IndicesDeleteComponentTemplateService {
+ s.errorTrace = &errorTrace
+ return s
+}
+
+// FilterPath specifies a list of filters used to reduce the response.
+func (s *IndicesDeleteComponentTemplateService) FilterPath(filterPath ...string) *IndicesDeleteComponentTemplateService {
+ s.filterPath = filterPath
+ return s
+}
+
+// Header adds a header to the request.
+func (s *IndicesDeleteComponentTemplateService) Header(name string, value string) *IndicesDeleteComponentTemplateService {
+ if s.headers == nil {
+ s.headers = http.Header{}
+ }
+ s.headers.Add(name, value)
+ return s
+}
+
+// Headers specifies the headers of the request.
+func (s *IndicesDeleteComponentTemplateService) Headers(headers http.Header) *IndicesDeleteComponentTemplateService {
+ s.headers = headers
+ return s
+}
+
+// Name is the name of the template.
+func (s *IndicesDeleteComponentTemplateService) Name(name string) *IndicesDeleteComponentTemplateService {
+ s.name = name
+ return s
+}
+
+// Timeout is an explicit operation timeout.
+func (s *IndicesDeleteComponentTemplateService) Timeout(timeout string) *IndicesDeleteComponentTemplateService {
+ s.timeout = timeout
+ return s
+}
+
+// MasterTimeout specifies the timeout for connection to master.
+func (s *IndicesDeleteComponentTemplateService) MasterTimeout(masterTimeout string) *IndicesDeleteComponentTemplateService {
+ s.masterTimeout = masterTimeout
+ return s
+}
+
+// buildURL builds the URL for the operation.
+func (s *IndicesDeleteComponentTemplateService) buildURL() (string, url.Values, error) {
+ // Build URL
+ path, err := uritemplates.Expand("/_component_template/{name}", map[string]string{
+ "name": s.name,
+ })
+ 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, ","))
+ }
+ if s.timeout != "" {
+ params.Set("timeout", s.timeout)
+ }
+ if s.masterTimeout != "" {
+ params.Set("master_timeout", s.masterTimeout)
+ }
+ return path, params, nil
+}
+
+// Validate checks if the operation is valid.
+func (s *IndicesDeleteComponentTemplateService) Validate() error {
+ var invalid []string
+ if s.name == "" {
+ invalid = append(invalid, "Name")
+ }
+ if len(invalid) > 0 {
+ return fmt.Errorf("missing required fields: %v", invalid)
+ }
+ return nil
+}
+
+// Do executes the operation.
+func (s *IndicesDeleteComponentTemplateService) Do(ctx context.Context) (*IndicesDeleteComponentTemplateResponse, 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(IndicesDeleteComponentTemplateResponse)
+ if err := s.client.decoder.Decode(res.Body, ret); err != nil {
+ return nil, err
+ }
+ return ret, nil
+}
+
+// IndicesDeleteComponentTemplateResponse is the response of IndicesDeleteComponentTemplateService.Do.
+type IndicesDeleteComponentTemplateResponse struct {
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
+}
diff --git a/vendor/github.com/olivere/elastic/v7/indices_get_component_template.go b/vendor/github.com/olivere/elastic/v7/indices_get_component_template.go
new file mode 100644
index 0000000000..d3d2d71aa8
--- /dev/null
+++ b/vendor/github.com/olivere/elastic/v7/indices_get_component_template.go
@@ -0,0 +1,207 @@
+// 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"
+)
+
+// IndicesGetComponentTemplateService returns a component template.
+//
+// See https://www.elastic.co/guide/en/elasticsearch/reference/7.10/getting-component-templates.html
+// for more details.
+type IndicesGetComponentTemplateService 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
+
+ name []string
+ masterTimeout string
+ flatSettings *bool
+ local *bool
+}
+
+// NewIndicesGetComponentTemplateService creates a new IndicesGetComponentTemplateService.
+func NewIndicesGetComponentTemplateService(client *Client) *IndicesGetComponentTemplateService {
+ return &IndicesGetComponentTemplateService{
+ client: client,
+ name: make([]string, 0),
+ }
+}
+
+// Pretty tells Elasticsearch whether to return a formatted JSON response.
+func (s *IndicesGetComponentTemplateService) Pretty(pretty bool) *IndicesGetComponentTemplateService {
+ s.pretty = &pretty
+ return s
+}
+
+// Human specifies whether human readable values should be returned in
+// the JSON response, e.g. "7.5mb".
+func (s *IndicesGetComponentTemplateService) Human(human bool) *IndicesGetComponentTemplateService {
+ s.human = &human
+ return s
+}
+
+// ErrorTrace specifies whether to include the stack trace of returned errors.
+func (s *IndicesGetComponentTemplateService) ErrorTrace(errorTrace bool) *IndicesGetComponentTemplateService {
+ s.errorTrace = &errorTrace
+ return s
+}
+
+// FilterPath specifies a list of filters used to reduce the response.
+func (s *IndicesGetComponentTemplateService) FilterPath(filterPath ...string) *IndicesGetComponentTemplateService {
+ s.filterPath = filterPath
+ return s
+}
+
+// Header adds a header to the request.
+func (s *IndicesGetComponentTemplateService) Header(name string, value string) *IndicesGetComponentTemplateService {
+ if s.headers == nil {
+ s.headers = http.Header{}
+ }
+ s.headers.Add(name, value)
+ return s
+}
+
+// Headers specifies the headers of the request.
+func (s *IndicesGetComponentTemplateService) Headers(headers http.Header) *IndicesGetComponentTemplateService {
+ s.headers = headers
+ return s
+}
+
+// Name is the name of the component template.
+func (s *IndicesGetComponentTemplateService) Name(name ...string) *IndicesGetComponentTemplateService {
+ s.name = append(s.name, name...)
+ return s
+}
+
+// FlatSettings is returns settings in flat format (default: false).
+func (s *IndicesGetComponentTemplateService) FlatSettings(flatSettings bool) *IndicesGetComponentTemplateService {
+ s.flatSettings = &flatSettings
+ return s
+}
+
+// Local indicates whether to return local information, i.e. do not retrieve
+// the state from master node (default: false).
+func (s *IndicesGetComponentTemplateService) Local(local bool) *IndicesGetComponentTemplateService {
+ s.local = &local
+ return s
+}
+
+// MasterTimeout specifies the timeout for connection to master.
+func (s *IndicesGetComponentTemplateService) MasterTimeout(masterTimeout string) *IndicesGetComponentTemplateService {
+ s.masterTimeout = masterTimeout
+ return s
+}
+
+// buildURL builds the URL for the operation.
+func (s *IndicesGetComponentTemplateService) buildURL() (string, url.Values, error) {
+ // Build URL
+ var err error
+ var path string
+ if len(s.name) > 0 {
+ path, err = uritemplates.Expand("/_component_template/{name}", map[string]string{
+ "name": strings.Join(s.name, ","),
+ })
+ } else {
+ path = "/_component_template"
+ }
+ 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, ","))
+ }
+ if s.flatSettings != nil {
+ params.Set("flat_settings", fmt.Sprintf("%v", *s.flatSettings))
+ }
+ if s.local != nil {
+ params.Set("local", fmt.Sprintf("%v", *s.local))
+ }
+ if s.masterTimeout != "" {
+ params.Set("master_timeout", s.masterTimeout)
+ }
+ return path, params, nil
+}
+
+// Validate checks if the operation is valid.
+func (s *IndicesGetComponentTemplateService) Validate() error {
+ return nil
+}
+
+// Do executes the operation.
+func (s *IndicesGetComponentTemplateService) Do(ctx context.Context) (*IndicesGetComponentTemplateResponse, 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
+ var ret *IndicesGetComponentTemplateResponse
+ if err := s.client.decoder.Decode(res.Body, &ret); err != nil {
+ return nil, err
+ }
+ return ret, nil
+}
+
+// IndicesGetComponentTemplateResponse is the response of IndicesGetComponentTemplateService.Do.
+type IndicesGetComponentTemplateResponse struct {
+ ComponentTemplates []IndicesGetComponentTemplates `json:"component_templates"`
+}
+
+type IndicesGetComponentTemplates struct {
+ Name string `json:"name"`
+ ComponentTemplate *IndicesGetComponentTemplate `json:"component_template"`
+}
+
+type IndicesGetComponentTemplate struct {
+ Version int `json:"version,omitempty"`
+ Template *IndicesGetComponentTemplateData `json:"template,omitempty"`
+}
+
+type IndicesGetComponentTemplateData struct {
+ Settings map[string]interface{} `json:"settings,omitempty"`
+ Mappings map[string]interface{} `json:"mappings,omitempty"`
+ Aliases map[string]interface{} `json:"aliases,omitempty"`
+}
diff --git a/vendor/github.com/olivere/elastic/v7/indices_put_component_template.go b/vendor/github.com/olivere/elastic/v7/indices_put_component_template.go
new file mode 100644
index 0000000000..ec6b93d15a
--- /dev/null
+++ b/vendor/github.com/olivere/elastic/v7/indices_put_component_template.go
@@ -0,0 +1,221 @@
+// 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"
+)
+
+// IndicesPutComponentTemplateService creates or updates component templates.
+//
+// See https://www.elastic.co/guide/en/elasticsearch/reference/7.10/indices-component-template.html
+// for more details on this API.
+type IndicesPutComponentTemplateService 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
+
+ name string
+ create *bool
+ cause string
+ masterTimeout string
+
+ bodyJson interface{}
+ bodyString string
+}
+
+// NewIndicesPutComponentTemplateService creates a new IndicesPutComponentTemplateService.
+func NewIndicesPutComponentTemplateService(client *Client) *IndicesPutComponentTemplateService {
+ return &IndicesPutComponentTemplateService{
+ client: client,
+ }
+}
+
+// Pretty tells Elasticsearch whether to return a formatted JSON response.
+func (s *IndicesPutComponentTemplateService) Pretty(pretty bool) *IndicesPutComponentTemplateService {
+ s.pretty = &pretty
+ return s
+}
+
+// Human specifies whether human readable values should be returned in
+// the JSON response, e.g. "7.5mb".
+func (s *IndicesPutComponentTemplateService) Human(human bool) *IndicesPutComponentTemplateService {
+ s.human = &human
+ return s
+}
+
+// ErrorTrace specifies whether to include the stack trace of returned errors.
+func (s *IndicesPutComponentTemplateService) ErrorTrace(errorTrace bool) *IndicesPutComponentTemplateService {
+ s.errorTrace = &errorTrace
+ return s
+}
+
+// FilterPath specifies a list of filters used to reduce the response.
+func (s *IndicesPutComponentTemplateService) FilterPath(filterPath ...string) *IndicesPutComponentTemplateService {
+ s.filterPath = filterPath
+ return s
+}
+
+// Header adds a header to the request.
+func (s *IndicesPutComponentTemplateService) Header(name string, value string) *IndicesPutComponentTemplateService {
+ if s.headers == nil {
+ s.headers = http.Header{}
+ }
+ s.headers.Add(name, value)
+ return s
+}
+
+// Headers specifies the headers of the request.
+func (s *IndicesPutComponentTemplateService) Headers(headers http.Header) *IndicesPutComponentTemplateService {
+ s.headers = headers
+ return s
+}
+
+// Name is the name of the component template.
+func (s *IndicesPutComponentTemplateService) Name(name string) *IndicesPutComponentTemplateService {
+ s.name = name
+ return s
+}
+
+// Create indicates whether the component template should only be added if
+// new or can also replace an existing one.
+func (s *IndicesPutComponentTemplateService) Create(create bool) *IndicesPutComponentTemplateService {
+ s.create = &create
+ return s
+}
+
+// Cause is the user-defined reason for creating/updating the the component template.
+func (s *IndicesPutComponentTemplateService) Cause(cause string) *IndicesPutComponentTemplateService {
+ s.cause = cause
+ return s
+}
+
+// MasterTimeout specifies the timeout for connection to master.
+func (s *IndicesPutComponentTemplateService) MasterTimeout(masterTimeout string) *IndicesPutComponentTemplateService {
+ s.masterTimeout = masterTimeout
+ return s
+}
+
+// BodyJson is the component template definition as a JSON serializable
+// type, e.g. map[string]interface{}.
+func (s *IndicesPutComponentTemplateService) BodyJson(body interface{}) *IndicesPutComponentTemplateService {
+ s.bodyJson = body
+ return s
+}
+
+// BodyString is the component template definition as a raw string.
+func (s *IndicesPutComponentTemplateService) BodyString(body string) *IndicesPutComponentTemplateService {
+ s.bodyString = body
+ return s
+}
+
+// buildURL builds the URL for the operation.
+func (s *IndicesPutComponentTemplateService) buildURL() (string, url.Values, error) {
+ // Build URL
+ path, err := uritemplates.Expand("/_component_template/{name}", map[string]string{
+ "name": s.name,
+ })
+ 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, ","))
+ }
+ if s.create != nil {
+ params.Set("create", fmt.Sprint(*s.create))
+ }
+ if s.cause != "" {
+ params.Set("cause", s.cause)
+ }
+ if s.masterTimeout != "" {
+ params.Set("master_timeout", s.masterTimeout)
+ }
+ return path, params, nil
+}
+
+// Validate checks if the operation is valid.
+func (s *IndicesPutComponentTemplateService) Validate() error {
+ var invalid []string
+ if s.name == "" {
+ invalid = append(invalid, "Name")
+ }
+ if s.bodyString == "" && s.bodyJson == nil {
+ invalid = append(invalid, "BodyJson")
+ }
+ if len(invalid) > 0 {
+ return fmt.Errorf("missing required fields: %v", invalid)
+ }
+ return nil
+}
+
+// Do executes the operation.
+func (s *IndicesPutComponentTemplateService) Do(ctx context.Context) (*IndicesPutComponentTemplateResponse, 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
+ }
+
+ // Setup HTTP request body
+ var body interface{}
+ if s.bodyJson != nil {
+ body = s.bodyJson
+ } else {
+ body = s.bodyString
+ }
+
+ // Get HTTP response
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "PUT",
+ Path: path,
+ Params: params,
+ Body: body,
+ Headers: s.headers,
+ })
+ if err != nil {
+ return nil, err
+ }
+
+ // Return operation response
+ ret := new(IndicesPutComponentTemplateResponse)
+ if err := s.client.decoder.Decode(res.Body, ret); err != nil {
+ return nil, err
+ }
+ return ret, nil
+}
+
+// IndicesPutComponentTemplateResponse is the response of IndicesPutComponentTemplateService.Do.
+type IndicesPutComponentTemplateResponse struct {
+ Acknowledged bool `json:"acknowledged"`
+ ShardsAcknowledged bool `json:"shards_acknowledged"`
+ Index string `json:"index,omitempty"`
+}
diff --git a/vendor/github.com/olivere/elastic/v7/search.go b/vendor/github.com/olivere/elastic/v7/search.go
index f47fdf5cba..6e0b476ac7 100644
--- a/vendor/github.com/olivere/elastic/v7/search.go
+++ b/vendor/github.com/olivere/elastic/v7/search.go
@@ -691,7 +691,7 @@ func (r *SearchResult) Each(typ reflect.Type) []interface{} {
if r.Hits == nil || r.Hits.Hits == nil || len(r.Hits.Hits) == 0 {
return nil
}
- var slice []interface{}
+ slice := make([]interface{}, 0, len(r.Hits.Hits))
for _, hit := range r.Hits.Hits {
v := reflect.New(typ).Elem()
if hit.Source == nil {
diff --git a/vendor/github.com/olivere/elastic/v7/search_aggs.go b/vendor/github.com/olivere/elastic/v7/search_aggs.go
index 72ea92fc8b..bf452f706b 100644
--- a/vendor/github.com/olivere/elastic/v7/search_aggs.go
+++ b/vendor/github.com/olivere/elastic/v7/search_aggs.go
@@ -369,6 +369,21 @@ func (a Aggregations) Terms(name string) (*AggregationBucketKeyItems, bool) {
return nil, false
}
+// MultiTerms returns multi terms aggregation results.
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/7.13/search-aggregations-bucket-multi-terms-aggregation.html
+func (a Aggregations) MultiTerms(name string) (*AggregationBucketMultiKeyItems, bool) {
+ if raw, found := a[name]; found {
+ agg := new(AggregationBucketMultiKeyItems)
+ if raw == nil {
+ return agg, true
+ }
+ if err := json.Unmarshal(raw, agg); err == nil {
+ return agg, true
+ }
+ }
+ return nil, false
+}
+
// SignificantTerms returns significant terms aggregation results.
// See: https://www.elastic.co/guide/en/elasticsearch/reference/7.0/search-aggregations-bucket-significantterms-aggregation.html
func (a Aggregations) SignificantTerms(name string) (*AggregationBucketSignificantTerms, bool) {
@@ -840,6 +855,22 @@ func (a Aggregations) ScriptedMetric(name string) (*AggregationScriptedMetric, b
return nil, false
}
+// TopMetrics returns top metrics aggregation results.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/search-aggregations-metrics-top-metrics.html
+//for details
+func (a Aggregations) TopMetrics(name string) (*AggregationTopMetricsItems, bool) {
+ if raw, found := a[name]; found {
+ agg := new(AggregationTopMetricsItems)
+ if raw == nil {
+ return agg, true
+ }
+ if err := json.Unmarshal(raw, agg); err == nil {
+ return agg, true
+ }
+ }
+ return nil, false
+}
+
// -- Single value metric --
// AggregationValueMetric is a single-value metric, returned e.g. by a
@@ -1326,6 +1357,71 @@ func (a *AggregationBucketKeyItem) UnmarshalJSON(data []byte) error {
return nil
}
+// AggregationBucketMultiKeyItems is a bucket aggregation that is returned
+// with a multi terms aggregation.
+type AggregationBucketMultiKeyItems struct {
+ Aggregations
+
+ DocCountErrorUpperBound int64 //`json:"doc_count_error_upper_bound"`
+ SumOfOtherDocCount int64 //`json:"sum_other_doc_count"`
+ Buckets []*AggregationBucketMultiKeyItem //`json:"buckets"`
+ Meta map[string]interface{} // `json:"meta,omitempty"`
+}
+
+// UnmarshalJSON decodes JSON data and initializes an AggregationBucketMultiKeyItems structure.
+func (a *AggregationBucketMultiKeyItems) UnmarshalJSON(data []byte) error {
+ var aggs map[string]json.RawMessage
+ if err := json.Unmarshal(data, &aggs); err != nil {
+ return err
+ }
+ if v, ok := aggs["doc_count_error_upper_bound"]; ok && v != nil {
+ json.Unmarshal(v, &a.DocCountErrorUpperBound)
+ }
+ if v, ok := aggs["sum_other_doc_count"]; ok && v != nil {
+ json.Unmarshal(v, &a.SumOfOtherDocCount)
+ }
+ if v, ok := aggs["buckets"]; ok && v != nil {
+ json.Unmarshal(v, &a.Buckets)
+ }
+ if v, ok := aggs["meta"]; ok && v != nil {
+ json.Unmarshal(v, &a.Meta)
+ }
+ a.Aggregations = aggs
+ return nil
+}
+
+// AggregationBucketMultiKeyItem is a single bucket of an AggregationBucketMultiKeyItems structure.
+type AggregationBucketMultiKeyItem struct {
+ Aggregations
+
+ Key []interface{} //`json:"key"`
+ KeyAsString *string //`json:"key_as_string"`
+ KeyNumber []json.Number
+ DocCount int64 //`json:"doc_count"`
+}
+
+// UnmarshalJSON decodes JSON data and initializes an AggregationBucketMultiKeyItem structure.
+func (a *AggregationBucketMultiKeyItem) UnmarshalJSON(data []byte) error {
+ var aggs map[string]json.RawMessage
+ dec := json.NewDecoder(bytes.NewReader(data))
+ dec.UseNumber()
+ if err := dec.Decode(&aggs); err != nil {
+ return err
+ }
+ if v, ok := aggs["key"]; ok && v != nil {
+ json.Unmarshal(v, &a.Key)
+ json.Unmarshal(v, &a.KeyNumber)
+ }
+ if v, ok := aggs["key_as_string"]; ok && v != nil {
+ json.Unmarshal(v, &a.KeyAsString)
+ }
+ if v, ok := aggs["doc_count"]; ok && v != nil {
+ json.Unmarshal(v, &a.DocCount)
+ }
+ a.Aggregations = aggs
+ return nil
+}
+
// -- Bucket types for significant terms --
// AggregationBucketSignificantTerms is a bucket aggregation returned
@@ -1804,3 +1900,16 @@ func (a *AggregationScriptedMetric) UnmarshalJSON(data []byte) error {
a.Aggregations = aggs
return nil
}
+
+// AggregationTopMetricsItems is the value returned by the top metrics aggregation
+type AggregationTopMetricsItems struct {
+ Aggregations
+
+ Top []AggregationTopMetricsItem `json:"top"`
+}
+
+// AggregationTopMetricsItem is a set of metrics returned for the top document or documents
+type AggregationTopMetricsItem struct {
+ Sort []interface{} `json:"sort"` // sort information
+ Metrics map[string]interface{} `json:"metrics"` // returned metrics
+}
diff --git a/vendor/github.com/olivere/elastic/v7/search_aggs_bucket_multi_terms.go b/vendor/github.com/olivere/elastic/v7/search_aggs_bucket_multi_terms.go
new file mode 100644
index 0000000000..3eb493b44f
--- /dev/null
+++ b/vendor/github.com/olivere/elastic/v7/search_aggs_bucket_multi_terms.go
@@ -0,0 +1,316 @@
+// 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
+
+// MultiTermsAggregation is a multi-bucket value source based aggregation
+// where buckets are dynamically built - one per unique set of values.
+// The multi terms aggregation is very similar to the terms aggregation,
+// however in most cases it will be slower than the terms aggregation and will
+// consume more memory. Therefore, if the same set of fields is constantly
+// used, it would be more efficient to index a combined key for this fields
+// as a separate field and use the terms aggregation on this field.
+//
+// See https://www.elastic.co/guide/en/elasticsearch/reference/7.13/search-aggregations-bucket-multi-terms-aggregation.html
+type MultiTermsAggregation struct {
+ multiTerms []MultiTerm
+ subAggregations map[string]Aggregation
+ meta map[string]interface{}
+
+ size *int
+ shardSize *int
+ minDocCount *int
+ shardMinDocCount *int
+ collectionMode string
+ showTermDocCountError *bool
+ order []MultiTermsOrder
+}
+
+// NewMultiTermsAggregation initializes a new MultiTermsAggregation.
+func NewMultiTermsAggregation() *MultiTermsAggregation {
+ return &MultiTermsAggregation{
+ subAggregations: make(map[string]Aggregation),
+ }
+}
+
+// Terms adds a slice of field names to return in the aggregation.
+//
+// Notice that it appends to existing terms, so you can use Terms more than
+// once, and mix with MultiTerms method.
+func (a *MultiTermsAggregation) Terms(fields ...string) *MultiTermsAggregation {
+ for _, field := range fields {
+ a.multiTerms = append(a.multiTerms, MultiTerm{Field: field})
+ }
+ return a
+}
+
+// MultiTerms adds a slice of MultiTerm instances to return in the aggregation.
+//
+// Notice that it appends to existing terms, so you can use MultiTerms more
+// than once, and mix with Terms method.
+func (a *MultiTermsAggregation) MultiTerms(multiTerms ...MultiTerm) *MultiTermsAggregation {
+ a.multiTerms = append(a.multiTerms, multiTerms...)
+ return a
+}
+
+func (a *MultiTermsAggregation) SubAggregation(name string, subAggregation Aggregation) *MultiTermsAggregation {
+ a.subAggregations[name] = subAggregation
+ return a
+}
+
+// Meta sets the meta data to be included in the aggregation response.
+func (a *MultiTermsAggregation) Meta(metaData map[string]interface{}) *MultiTermsAggregation {
+ a.meta = metaData
+ return a
+}
+
+func (a *MultiTermsAggregation) Size(size int) *MultiTermsAggregation {
+ a.size = &size
+ return a
+}
+
+func (a *MultiTermsAggregation) ShardSize(shardSize int) *MultiTermsAggregation {
+ a.shardSize = &shardSize
+ return a
+}
+
+func (a *MultiTermsAggregation) MinDocCount(minDocCount int) *MultiTermsAggregation {
+ a.minDocCount = &minDocCount
+ return a
+}
+
+func (a *MultiTermsAggregation) ShardMinDocCount(shardMinDocCount int) *MultiTermsAggregation {
+ a.shardMinDocCount = &shardMinDocCount
+ return a
+}
+
+func (a *MultiTermsAggregation) Order(order string, asc bool) *MultiTermsAggregation {
+ a.order = append(a.order, MultiTermsOrder{Field: order, Ascending: asc})
+ return a
+}
+
+func (a *MultiTermsAggregation) OrderByCount(asc bool) *MultiTermsAggregation {
+ // "order" : { "_count" : "asc" }
+ a.order = append(a.order, MultiTermsOrder{Field: "_count", Ascending: asc})
+ return a
+}
+
+func (a *MultiTermsAggregation) OrderByCountAsc() *MultiTermsAggregation {
+ return a.OrderByCount(true)
+}
+
+func (a *MultiTermsAggregation) OrderByCountDesc() *MultiTermsAggregation {
+ return a.OrderByCount(false)
+}
+
+func (a *MultiTermsAggregation) OrderByKey(asc bool) *MultiTermsAggregation {
+ // "order" : { "_term" : "asc" }
+ a.order = append(a.order, MultiTermsOrder{Field: "_key", Ascending: asc})
+ return a
+}
+
+func (a *MultiTermsAggregation) OrderByKeyAsc() *MultiTermsAggregation {
+ return a.OrderByKey(true)
+}
+
+func (a *MultiTermsAggregation) OrderByKeyDesc() *MultiTermsAggregation {
+ return a.OrderByKey(false)
+}
+
+// OrderByAggregation creates a bucket ordering strategy which sorts buckets
+// based on a single-valued calc get.
+func (a *MultiTermsAggregation) OrderByAggregation(aggName string, asc bool) *MultiTermsAggregation {
+ // {
+ // "aggs": {
+ // "genres_and_products": {
+ // "multi_terms": {
+ // "terms": [
+ // {
+ // "field": "genre"
+ // },
+ // {
+ // "field": "product"
+ // }
+ // ],
+ // "order": {
+ // "total_quantity": "desc"
+ // }
+ // },
+ // "aggs": {
+ // "total_quantity": {
+ // "sum": {
+ // "field": "quantity"
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ a.order = append(a.order, MultiTermsOrder{Field: aggName, Ascending: asc})
+ return a
+}
+
+// OrderByAggregationAndMetric creates a bucket ordering strategy which
+// sorts buckets based on a multi-valued calc get.
+func (a *MultiTermsAggregation) OrderByAggregationAndMetric(aggName, metric string, asc bool) *MultiTermsAggregation {
+ // {
+ // "aggs": {
+ // "genres_and_products": {
+ // "multi_terms": {
+ // "terms": [
+ // {
+ // "field": "genre"
+ // },
+ // {
+ // "field": "product"
+ // }
+ // ],
+ // "order": {
+ // "total_quantity": "desc"
+ // }
+ // },
+ // "aggs": {
+ // "total_quantity": {
+ // "sum": {
+ // "field": "quantity"
+ // }
+ // }
+ // }
+ // }
+ // }
+ // }
+ a.order = append(a.order, MultiTermsOrder{Field: aggName + "." + metric, Ascending: asc})
+ return a
+}
+
+// Collection mode can be depth_first or breadth_first as of 1.4.0.
+func (a *MultiTermsAggregation) CollectionMode(collectionMode string) *MultiTermsAggregation {
+ a.collectionMode = collectionMode
+ return a
+}
+
+func (a *MultiTermsAggregation) ShowTermDocCountError(showTermDocCountError bool) *MultiTermsAggregation {
+ a.showTermDocCountError = &showTermDocCountError
+ return a
+}
+
+func (a *MultiTermsAggregation) Source() (interface{}, error) {
+ // Example:
+ // {
+ // "aggs": {
+ // "genres_and_products": {
+ // "multi_terms": {
+ // "terms": [
+ // {
+ // "field": "genre"
+ // },
+ // {
+ // "field": "product"
+ // }
+ // ]
+ // }
+ // }
+ // }
+ // }
+ // This method returns only the "multi_terms": { "terms": [ { "field": "genre" }, { "field": "product" } ] } part.
+
+ source := make(map[string]interface{})
+ opts := make(map[string]interface{})
+ source["multi_terms"] = opts
+
+ // ValuesSourceAggregationBuilder
+ terms := make([]interface{}, len(a.multiTerms))
+ for i := range a.multiTerms {
+ s, err := a.multiTerms[i].Source()
+ if err != nil {
+ return nil, err
+ }
+ terms[i] = s
+ }
+ opts["terms"] = terms
+
+ // TermsBuilder
+ if a.size != nil && *a.size >= 0 {
+ opts["size"] = *a.size
+ }
+ if a.shardSize != nil && *a.shardSize >= 0 {
+ opts["shard_size"] = *a.shardSize
+ }
+ if a.minDocCount != nil && *a.minDocCount >= 0 {
+ opts["min_doc_count"] = *a.minDocCount
+ }
+ if a.shardMinDocCount != nil && *a.shardMinDocCount >= 0 {
+ opts["shard_min_doc_count"] = *a.shardMinDocCount
+ }
+ if a.showTermDocCountError != nil {
+ opts["show_term_doc_count_error"] = *a.showTermDocCountError
+ }
+ if a.collectionMode != "" {
+ opts["collect_mode"] = a.collectionMode
+ }
+ if len(a.order) > 0 {
+ var orderSlice []interface{}
+ for _, order := range a.order {
+ src, err := order.Source()
+ if err != nil {
+ return nil, err
+ }
+ orderSlice = append(orderSlice, src)
+ }
+ opts["order"] = orderSlice
+ }
+
+ // AggregationBuilder (SubAggregations)
+ if len(a.subAggregations) > 0 {
+ aggsMap := make(map[string]interface{})
+ source["aggregations"] = aggsMap
+ for name, aggregate := range a.subAggregations {
+ src, err := aggregate.Source()
+ if err != nil {
+ return nil, err
+ }
+ aggsMap[name] = src
+ }
+ }
+
+ // Add Meta data if available
+ if len(a.meta) > 0 {
+ source["meta"] = a.meta
+ }
+
+ return source, nil
+}
+
+// MultiTermsOrder specifies a single order field for a multi terms aggregation.
+type MultiTermsOrder struct {
+ Field string
+ Ascending bool
+}
+
+// Source returns serializable JSON of the MultiTermsOrder.
+func (order *MultiTermsOrder) Source() (interface{}, error) {
+ source := make(map[string]string)
+ if order.Ascending {
+ source[order.Field] = "asc"
+ } else {
+ source[order.Field] = "desc"
+ }
+ return source, nil
+}
+
+// MultiTerm specifies a single term field for a multi terms aggregation.
+type MultiTerm struct {
+ Field string
+ Missing interface{}
+}
+
+// Source returns serializable JSON of the MultiTerm.
+func (term *MultiTerm) Source() (interface{}, error) {
+ source := make(map[string]interface{})
+ source["field"] = term.Field
+ if term.Missing != nil {
+ source["missing"] = term.Missing
+ }
+ return source, nil
+}
diff --git a/vendor/github.com/olivere/elastic/v7/search_aggs_metrics_top_metrics.go b/vendor/github.com/olivere/elastic/v7/search_aggs_metrics_top_metrics.go
new file mode 100644
index 0000000000..1a450a86e3
--- /dev/null
+++ b/vendor/github.com/olivere/elastic/v7/search_aggs_metrics_top_metrics.go
@@ -0,0 +1,83 @@
+// 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 "errors"
+
+// TopMetricsAggregation selects metrics from the document with the largest or smallest "sort" value.
+// top_metrics is fairly similar to top_hits in spirit but because it is more limited it is able to do
+// its job using less memory and is often faster.
+//
+// See: https://www.elastic.co/guide/en/elasticsearch/reference/7.0/search-aggregations-metrics-top-metrics.html
+type TopMetricsAggregation struct {
+ fields []string
+ sorter Sorter
+ size int
+}
+
+func NewTopMetricsAggregation() *TopMetricsAggregation {
+ return &TopMetricsAggregation{}
+}
+
+// Field adds a field to run aggregation against.
+func (a *TopMetricsAggregation) Field(field string) *TopMetricsAggregation {
+ a.fields = append(a.fields, field)
+ return a
+}
+
+// Sort adds a sort order.
+func (a *TopMetricsAggregation) Sort(field string, ascending bool) *TopMetricsAggregation {
+ a.sorter = SortInfo{Field: field, Ascending: ascending}
+ return a
+}
+
+// SortWithInfo adds a sort order.
+func (a *TopMetricsAggregation) SortWithInfo(info SortInfo) *TopMetricsAggregation {
+ a.sorter = info
+ return a
+}
+
+// SortBy adds a sort order.
+func (a *TopMetricsAggregation) SortBy(sorter Sorter) *TopMetricsAggregation {
+ a.sorter = sorter
+ return a
+}
+
+// Size sets the number of top documents returned by the aggregation. The default size is 1.
+func (a *TopMetricsAggregation) Size(size int) *TopMetricsAggregation {
+ a.size = size
+ return a
+}
+
+func (a *TopMetricsAggregation) Source() (interface{}, error) {
+ params := make(map[string]interface{})
+
+ if len(a.fields) == 0 {
+ return nil, errors.New("field list is required for the top metrics aggregation")
+ }
+ metrics := make([]interface{}, len(a.fields))
+ for idx, field := range a.fields {
+ metrics[idx] = map[string]string{"field": field}
+ }
+ params["metrics"] = metrics
+
+ if a.sorter == nil {
+ return nil, errors.New("sorter is required for the top metrics aggregation")
+ }
+ sortSource, err := a.sorter.Source()
+ if err != nil {
+ return nil, err
+ }
+ params["sort"] = sortSource
+
+ if a.size > 1 {
+ params["size"] = a.size
+ }
+
+ source := map[string]interface{}{
+ "top_metrics": params,
+ }
+ return source, nil
+}
diff --git a/vendor/github.com/olivere/elastic/v7/search_queries_match_bool_prefix.go b/vendor/github.com/olivere/elastic/v7/search_queries_match_bool_prefix.go
new file mode 100644
index 0000000000..5bbc7782f6
--- /dev/null
+++ b/vendor/github.com/olivere/elastic/v7/search_queries_match_bool_prefix.go
@@ -0,0 +1,130 @@
+// 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
+
+// MatchBoolPrefixQuery query analyzes its input and constructs a bool query from the terms.
+// Each term except the last is used in a term query. The last term is used in a prefix query.
+//
+// For more details, see
+// https://www.elastic.co/guide/en/elasticsearch/reference/7.0/query-dsl-match-bool-prefix-query.html
+type MatchBoolPrefixQuery struct {
+ name string
+ queryText interface{}
+ analyzer string
+ minimumShouldMatch string
+ operator string
+ fuzziness string
+ prefixLength *int
+ maxExpansions *int
+ fuzzyTranspositions *bool
+ fuzzyRewrite string
+ boost *float64
+}
+
+// NewMatchBoolPrefixQuery creates and initializes a new MatchBoolPrefixQuery.
+func NewMatchBoolPrefixQuery(name string, queryText interface{}) *MatchBoolPrefixQuery {
+ return &MatchBoolPrefixQuery{name: name, queryText: queryText}
+}
+
+// Analyzer explicitly sets the analyzer to use. It defaults to use explicit
+// mapping config for the field, or, if not set, the default search analyzer.
+func (q *MatchBoolPrefixQuery) Analyzer(analyzer string) *MatchBoolPrefixQuery {
+ q.analyzer = analyzer
+ return q
+}
+
+// MinimumShouldMatch sets the optional minimumShouldMatch value to apply to the query.
+func (q *MatchBoolPrefixQuery) MinimumShouldMatch(minimumShouldMatch string) *MatchBoolPrefixQuery {
+ q.minimumShouldMatch = minimumShouldMatch
+ return q
+}
+
+// Operator sets the operator to use when using a boolean query.
+// Can be "AND" or "OR" (default).
+func (q *MatchBoolPrefixQuery) Operator(operator string) *MatchBoolPrefixQuery {
+ q.operator = operator
+ return q
+}
+
+// Fuzziness sets the edit distance for fuzzy queries. Default is "AUTO".
+func (q *MatchBoolPrefixQuery) Fuzziness(fuzziness string) *MatchBoolPrefixQuery {
+ q.fuzziness = fuzziness
+ return q
+}
+
+// PrefixLength is the number of beginning characters left unchanged for fuzzy matching. Defaults to 0.
+func (q *MatchBoolPrefixQuery) PrefixLength(prefixLength int) *MatchBoolPrefixQuery {
+ q.prefixLength = &prefixLength
+ return q
+}
+
+// MaxExpansions sets the number of term expansions to use.
+func (q *MatchBoolPrefixQuery) MaxExpansions(n int) *MatchBoolPrefixQuery {
+ q.maxExpansions = &n
+ return q
+}
+
+// FuzzyTranspositions if true, edits for fuzzy matching include transpositions of two adjacent
+// characters (ab → ba). Defaults to true.
+func (q *MatchBoolPrefixQuery) FuzzyTranspositions(fuzzyTranspositions bool) *MatchBoolPrefixQuery {
+ q.fuzzyTranspositions = &fuzzyTranspositions
+ return q
+}
+
+// FuzzyRewrite sets the fuzzy_rewrite parameter controlling how the
+// fuzzy query will get rewritten.
+func (q *MatchBoolPrefixQuery) FuzzyRewrite(fuzzyRewrite string) *MatchBoolPrefixQuery {
+ q.fuzzyRewrite = fuzzyRewrite
+ return q
+}
+
+// Boost sets the boost to apply to this query.
+func (q *MatchBoolPrefixQuery) Boost(boost float64) *MatchBoolPrefixQuery {
+ q.boost = &boost
+ return q
+}
+
+// Source returns JSON for the function score query.
+func (q *MatchBoolPrefixQuery) Source() (interface{}, error) {
+ source := make(map[string]interface{})
+
+ match := make(map[string]interface{})
+ source["match_bool_prefix"] = match
+
+ query := make(map[string]interface{})
+ match[q.name] = query
+
+ query["query"] = q.queryText
+
+ if q.analyzer != "" {
+ query["analyzer"] = q.analyzer
+ }
+ if q.minimumShouldMatch != "" {
+ query["minimum_should_match"] = q.minimumShouldMatch
+ }
+ if q.operator != "" {
+ query["operator"] = q.operator
+ }
+ if q.fuzziness != "" {
+ query["fuzziness"] = q.fuzziness
+ }
+ if q.prefixLength != nil {
+ query["prefix_length"] = *q.prefixLength
+ }
+ if q.maxExpansions != nil {
+ query["max_expansions"] = *q.maxExpansions
+ }
+ if q.fuzzyTranspositions != nil {
+ query["fuzzy_transpositions"] = *q.fuzzyTranspositions
+ }
+ if q.fuzzyRewrite != "" {
+ query["fuzzy_rewrite"] = q.fuzzyRewrite
+ }
+ if q.boost != nil {
+ query["boost"] = *q.boost
+ }
+
+ return source, nil
+}
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 8178aac3f4..5e9813e197 100644
--- a/vendor/github.com/olivere/elastic/v7/search_queries_prefix.go
+++ b/vendor/github.com/olivere/elastic/v7/search_queries_prefix.go
@@ -10,11 +10,12 @@ package elastic
// For more details, see
// https://www.elastic.co/guide/en/elasticsearch/reference/7.0/query-dsl-prefix-query.html
type PrefixQuery struct {
- name string
- prefix string
- boost *float64
- rewrite string
- queryName string
+ name string
+ prefix string
+ boost *float64
+ rewrite string
+ caseInsensitive *bool
+ queryName string
}
// NewPrefixQuery creates and initializes a new PrefixQuery.
@@ -33,6 +34,11 @@ func (q *PrefixQuery) Rewrite(rewrite string) *PrefixQuery {
return q
}
+func (q *PrefixQuery) CaseInsensitive(caseInsensitive bool) *PrefixQuery {
+ q.caseInsensitive = &caseInsensitive
+ return q
+}
+
// QueryName sets the query name for the filter that can be used when
// searching for matched_filters per hit.
func (q *PrefixQuery) QueryName(queryName string) *PrefixQuery {
@@ -57,6 +63,9 @@ func (q *PrefixQuery) Source() (interface{}, error) {
if q.rewrite != "" {
subQuery["rewrite"] = q.rewrite
}
+ if q.caseInsensitive != nil {
+ subQuery["case_insensitive"] = *q.caseInsensitive
+ }
if q.queryName != "" {
subQuery["_name"] = q.queryName
}
diff --git a/vendor/github.com/olivere/elastic/v7/search_queries_regexp.go b/vendor/github.com/olivere/elastic/v7/search_queries_regexp.go
index 25a0c3d028..fd8370bd34 100644
--- a/vendor/github.com/olivere/elastic/v7/search_queries_regexp.go
+++ b/vendor/github.com/olivere/elastic/v7/search_queries_regexp.go
@@ -14,6 +14,7 @@ type RegexpQuery struct {
flags string
boost *float64
rewrite string
+ caseInsensitive *bool
queryName string
maxDeterminizedStates *int
}
@@ -46,6 +47,11 @@ func (q *RegexpQuery) Rewrite(rewrite string) *RegexpQuery {
return q
}
+func (q *RegexpQuery) CaseInsensitive(caseInsensitive bool) *RegexpQuery {
+ q.caseInsensitive = &caseInsensitive
+ return q
+}
+
// QueryName sets the query name for the filter that can be used
// when searching for matched_filters per hit
func (q *RegexpQuery) QueryName(queryName string) *RegexpQuery {
@@ -73,6 +79,9 @@ func (q *RegexpQuery) Source() (interface{}, error) {
if q.rewrite != "" {
x["rewrite"] = q.rewrite
}
+ if q.caseInsensitive != nil {
+ x["case_insensitive"] = *q.caseInsensitive
+ }
if q.queryName != "" {
x["name"] = q.queryName
}
diff --git a/vendor/github.com/olivere/elastic/v7/search_queries_term.go b/vendor/github.com/olivere/elastic/v7/search_queries_term.go
index 832e67e5e2..7d9c89dc68 100644
--- a/vendor/github.com/olivere/elastic/v7/search_queries_term.go
+++ b/vendor/github.com/olivere/elastic/v7/search_queries_term.go
@@ -10,10 +10,11 @@ package elastic
// For details, see
// https://www.elastic.co/guide/en/elasticsearch/reference/7.0/query-dsl-term-query.html
type TermQuery struct {
- name string
- value interface{}
- boost *float64
- queryName string
+ name string
+ value interface{}
+ boost *float64
+ caseInsensitive *bool
+ queryName string
}
// NewTermQuery creates and initializes a new TermQuery.
@@ -27,6 +28,11 @@ func (q *TermQuery) Boost(boost float64) *TermQuery {
return q
}
+func (q *TermQuery) CaseInsensitive(caseInsensitive bool) *TermQuery {
+ q.caseInsensitive = &caseInsensitive
+ return q
+}
+
// QueryName sets the query name for the filter that can be used
// when searching for matched_filters per hit
func (q *TermQuery) QueryName(queryName string) *TermQuery {
@@ -41,7 +47,7 @@ func (q *TermQuery) Source() (interface{}, error) {
tq := make(map[string]interface{})
source["term"] = tq
- if q.boost == nil && q.queryName == "" {
+ if q.boost == nil && q.caseInsensitive == nil && q.queryName == "" {
tq[q.name] = q.value
} else {
subQ := make(map[string]interface{})
@@ -49,6 +55,9 @@ func (q *TermQuery) Source() (interface{}, error) {
if q.boost != nil {
subQ["boost"] = *q.boost
}
+ if q.caseInsensitive != nil {
+ subQ["case_insensitive"] = *q.caseInsensitive
+ }
if q.queryName != "" {
subQ["_name"] = q.queryName
}
diff --git a/vendor/github.com/olivere/elastic/v7/search_queries_wildcard.go b/vendor/github.com/olivere/elastic/v7/search_queries_wildcard.go
index cbb26e9905..4cc1a8dbca 100644
--- a/vendor/github.com/olivere/elastic/v7/search_queries_wildcard.go
+++ b/vendor/github.com/olivere/elastic/v7/search_queries_wildcard.go
@@ -20,7 +20,7 @@ type WildcardQuery struct {
boost *float64
rewrite string
queryName string
- caseInsensitive bool
+ caseInsensitive *bool
}
// NewWildcardQuery creates and initializes a new WildcardQuery.
@@ -50,7 +50,7 @@ func (q *WildcardQuery) QueryName(queryName string) *WildcardQuery {
// CaseInsensitive sets case insensitive matching of this query.
func (q *WildcardQuery) CaseInsensitive(caseInsensitive bool) *WildcardQuery {
- q.caseInsensitive = caseInsensitive
+ q.caseInsensitive = &caseInsensitive
return q
}
@@ -84,8 +84,8 @@ func (q *WildcardQuery) Source() (interface{}, error) {
if q.queryName != "" {
wq["_name"] = q.queryName
}
- if q.caseInsensitive {
- wq["case_insensitive"] = true
+ if q.caseInsensitive != nil {
+ wq["case_insensitive"] = *q.caseInsensitive
}
return source, nil
diff --git a/vendor/github.com/olivere/elastic/v7/tasks_list.go b/vendor/github.com/olivere/elastic/v7/tasks_list.go
index dc1ad495cf..09aa6b6139 100644
--- a/vendor/github.com/olivere/elastic/v7/tasks_list.go
+++ b/vendor/github.com/olivere/elastic/v7/tasks_list.go
@@ -239,11 +239,6 @@ type TaskOperationFailure struct {
Reason *ErrorDetails `json:"reason"`
}
-type FailedNodeException struct {
- *ErrorDetails
- NodeId string `json:"node_id"`
-}
-
type DiscoveryNode struct {
Name string `json:"name"`
TransportAddress string `json:"transport_address"`