forked from forgejo/forgejo
Vendor Update (#14496)
* update code.gitea.io/sdk/gitea v0.13.1 -> v0.13.2 * update github.com/go-swagger/go-swagger v0.25.0 -> v0.26.0 * update github.com/google/uuid v1.1.2 -> v1.2.0 * update github.com/klauspost/compress v1.11.3 -> v1.11.7 * update github.com/lib/pq 083382b7e6fc -> v1.9.0 * update github.com/markbates/goth v1.65.0 -> v1.66.1 * update github.com/mattn/go-sqlite3 v1.14.4 -> v1.14.6 * update github.com/mgechev/revive 246eac737dc7 -> v1.0.3 * update github.com/minio/minio-go/v7 v7.0.6 -> v7.0.7 * update github.com/niklasfasching/go-org v1.3.2 -> v1.4.0 * update github.com/olivere/elastic/v7 v7.0.21 -> v7.0.22 * update github.com/pquerna/otp v1.2.0 -> v1.3.0 * update github.com/xanzy/go-gitlab v0.39.0 -> v0.42.0 * update github.com/yuin/goldmark v1.2.1 -> v1.3.1
This commit is contained in:
parent
e45bf12a34
commit
d1353e1f7c
403 changed files with 29737 additions and 14357 deletions
149
vendor/github.com/olivere/elastic/v7/client.go
generated
vendored
149
vendor/github.com/olivere/elastic/v7/client.go
generated
vendored
|
@ -25,7 +25,7 @@ import (
|
|||
|
||||
const (
|
||||
// Version is the current version of Elastic.
|
||||
Version = "7.0.21"
|
||||
Version = "7.0.22"
|
||||
|
||||
// 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.
|
||||
|
@ -145,6 +145,7 @@ type Client struct {
|
|||
gzipEnabled bool // gzip compression enabled or disabled (default)
|
||||
requiredPlugins []string // list of required plugins
|
||||
retrier Retrier // strategy for retries
|
||||
retryStatusCodes []int // HTTP status codes where to retry automatically (with retrier)
|
||||
headers http.Header // a list of default headers to add to each request
|
||||
}
|
||||
|
||||
|
@ -247,6 +248,7 @@ func NewSimpleClient(options ...ClientOptionFunc) (*Client, error) {
|
|||
sendGetBodyAs: DefaultSendGetBodyAs,
|
||||
gzipEnabled: DefaultGzipEnabled,
|
||||
retrier: noRetries, // no retries by default
|
||||
retryStatusCodes: nil, // no automatic retries for specific HTTP status codes
|
||||
deprecationlog: noDeprecationLog,
|
||||
}
|
||||
|
||||
|
@ -332,6 +334,7 @@ func DialContext(ctx context.Context, options ...ClientOptionFunc) (*Client, err
|
|||
sendGetBodyAs: DefaultSendGetBodyAs,
|
||||
gzipEnabled: DefaultGzipEnabled,
|
||||
retrier: noRetries, // no retries by default
|
||||
retryStatusCodes: nil, // no automatic retries for specific HTTP status codes
|
||||
deprecationlog: noDeprecationLog,
|
||||
}
|
||||
|
||||
|
@ -726,6 +729,17 @@ func SetRetrier(retrier Retrier) ClientOptionFunc {
|
|||
}
|
||||
}
|
||||
|
||||
// SetRetryStatusCodes specifies the HTTP status codes where the client
|
||||
// will retry automatically. Notice that retries call the specified retrier,
|
||||
// so calling SetRetryStatusCodes without setting a Retrier won't do anything
|
||||
// for retries.
|
||||
func SetRetryStatusCodes(statusCodes ...int) ClientOptionFunc {
|
||||
return func(c *Client) error {
|
||||
c.retryStatusCodes = statusCodes
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// SetHeaders adds a list of default HTTP headers that will be added to
|
||||
// each requests executed by PerformRequest.
|
||||
func SetHeaders(headers http.Header) ClientOptionFunc {
|
||||
|
@ -1262,15 +1276,16 @@ func (c *Client) mustActiveConn() error {
|
|||
|
||||
// PerformRequestOptions must be passed into PerformRequest.
|
||||
type PerformRequestOptions struct {
|
||||
Method string
|
||||
Path string
|
||||
Params url.Values
|
||||
Body interface{}
|
||||
ContentType string
|
||||
IgnoreErrors []int
|
||||
Retrier Retrier
|
||||
Headers http.Header
|
||||
MaxResponseSize int64
|
||||
Method string
|
||||
Path string
|
||||
Params url.Values
|
||||
Body interface{}
|
||||
ContentType string
|
||||
IgnoreErrors []int
|
||||
Retrier Retrier
|
||||
RetryStatusCodes []int
|
||||
Headers http.Header
|
||||
MaxResponseSize int64
|
||||
}
|
||||
|
||||
// PerformRequest does a HTTP request to Elasticsearch.
|
||||
|
@ -1294,9 +1309,23 @@ func (c *Client) PerformRequest(ctx context.Context, opt PerformRequestOptions)
|
|||
if opt.Retrier != nil {
|
||||
retrier = opt.Retrier
|
||||
}
|
||||
retryStatusCodes := c.retryStatusCodes
|
||||
if opt.RetryStatusCodes != nil {
|
||||
retryStatusCodes = opt.RetryStatusCodes
|
||||
}
|
||||
defaultHeaders := c.headers
|
||||
c.mu.RUnlock()
|
||||
|
||||
// retry returns true if statusCode indicates the request is to be retried
|
||||
retry := func(statusCode int) bool {
|
||||
for _, code := range retryStatusCodes {
|
||||
if code == statusCode {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var err error
|
||||
var conn *conn
|
||||
var req *Request
|
||||
|
@ -1404,6 +1433,21 @@ func (c *Client) PerformRequest(ctx context.Context, opt PerformRequestOptions)
|
|||
time.Sleep(wait)
|
||||
continue // try again
|
||||
}
|
||||
if retry(res.StatusCode) {
|
||||
n++
|
||||
wait, ok, rerr := retrier.Retry(ctx, n, (*http.Request)(req), res, err)
|
||||
if rerr != nil {
|
||||
c.errorf("elastic: %s is dead", conn.URL())
|
||||
conn.MarkAsDead()
|
||||
return nil, rerr
|
||||
}
|
||||
if ok {
|
||||
// retry
|
||||
retried = true
|
||||
time.Sleep(wait)
|
||||
continue // try again
|
||||
}
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
// Tracing
|
||||
|
@ -1698,30 +1742,82 @@ func (c *Client) Aliases() *AliasesService {
|
|||
return NewAliasesService(c)
|
||||
}
|
||||
|
||||
// IndexGetTemplate gets an index template.
|
||||
// Use XXXTemplate funcs to manage search templates.
|
||||
// -- Legacy templates --
|
||||
|
||||
// IndexGetTemplate gets an index template (v1/legacy version before 7.8).
|
||||
//
|
||||
// This service implements the legacy version of index templates as described
|
||||
// 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).
|
||||
func (c *Client) IndexGetTemplate(names ...string) *IndicesGetTemplateService {
|
||||
return NewIndicesGetTemplateService(c).Name(names...)
|
||||
}
|
||||
|
||||
// IndexTemplateExists gets check if an index template exists.
|
||||
// Use XXXTemplate funcs to manage search templates.
|
||||
// IndexTemplateExists gets check if an index template exists (v1/legacy version before 7.8).
|
||||
//
|
||||
// This service implements the legacy version of index templates as described
|
||||
// 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).
|
||||
func (c *Client) IndexTemplateExists(name string) *IndicesExistsTemplateService {
|
||||
return NewIndicesExistsTemplateService(c).Name(name)
|
||||
}
|
||||
|
||||
// IndexPutTemplate creates or updates an index template.
|
||||
// Use XXXTemplate funcs to manage search templates.
|
||||
// IndexPutTemplate creates or updates an index template (v1/legacy version before 7.8).
|
||||
//
|
||||
// This service implements the legacy version of index templates as described
|
||||
// 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).
|
||||
func (c *Client) IndexPutTemplate(name string) *IndicesPutTemplateService {
|
||||
return NewIndicesPutTemplateService(c).Name(name)
|
||||
}
|
||||
|
||||
// IndexDeleteTemplate deletes an index template.
|
||||
// Use XXXTemplate funcs to manage search templates.
|
||||
// IndexDeleteTemplate deletes an index template (v1/legacy version before 7.8).
|
||||
//
|
||||
// This service implements the legacy version of index templates as described
|
||||
// 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).
|
||||
func (c *Client) IndexDeleteTemplate(name string) *IndicesDeleteTemplateService {
|
||||
return NewIndicesDeleteTemplateService(c).Name(name)
|
||||
}
|
||||
|
||||
// -- Index templates --
|
||||
|
||||
// IndexPutIndexTemplate creates or updates an index template (new version after 7.8).
|
||||
//
|
||||
// This service implements the new version of index templates as described
|
||||
// on https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-put-template.html.
|
||||
//
|
||||
// See e.g. IndexPutTemplate for the v1/legacy version.
|
||||
func (c *Client) IndexPutIndexTemplate(name string) *IndicesPutIndexTemplateService {
|
||||
return NewIndicesPutIndexTemplateService(c).Name(name)
|
||||
}
|
||||
|
||||
// IndexGetIndexTemplate returns an index template (new version after 7.8).
|
||||
//
|
||||
// This service implements the new version of index templates as described
|
||||
// on https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-get-template.html.
|
||||
//
|
||||
// See e.g. IndexPutTemplate for the v1/legacy version.
|
||||
func (c *Client) IndexGetIndexTemplate(name string) *IndicesGetIndexTemplateService {
|
||||
return NewIndicesGetIndexTemplateService(c).Name(name)
|
||||
}
|
||||
|
||||
// IndexDeleteIndexTemplate deletes an index template (new version after 7.8).
|
||||
//
|
||||
// This service implements the new version of index templates as described
|
||||
// on https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-delete-template.html.
|
||||
//
|
||||
// See e.g. IndexPutTemplate for the v1/legacy version.
|
||||
func (c *Client) IndexDeleteIndexTemplate(name string) *IndicesDeleteIndexTemplateService {
|
||||
return NewIndicesDeleteIndexTemplateService(c).Name(name)
|
||||
}
|
||||
|
||||
// -- TODO Component templates --
|
||||
|
||||
// GetMapping gets a mapping.
|
||||
func (c *Client) GetMapping() *IndicesGetMappingService {
|
||||
return NewIndicesGetMappingService(c)
|
||||
|
@ -1930,6 +2026,23 @@ func (c *Client) XPackInfo() *XPackInfoService {
|
|||
return NewXPackInfoService(c)
|
||||
}
|
||||
|
||||
// -- X-Pack Async Search --
|
||||
|
||||
// XPackAsyncSearchSubmit starts an asynchronous search.
|
||||
func (c *Client) XPackAsyncSearchSubmit() *XPackAsyncSearchSubmit {
|
||||
return NewXPackAsyncSearchSubmit(c)
|
||||
}
|
||||
|
||||
// XPackAsyncSearchGet retrieves the outcome of an asynchronous search.
|
||||
func (c *Client) XPackAsyncSearchGet() *XPackAsyncSearchGet {
|
||||
return NewXPackAsyncSearchGet(c)
|
||||
}
|
||||
|
||||
// XPackAsyncSearchDelete deletes an asynchronous search.
|
||||
func (c *Client) XPackAsyncSearchDelete() *XPackAsyncSearchDelete {
|
||||
return NewXPackAsyncSearchDelete(c)
|
||||
}
|
||||
|
||||
// -- X-Pack Index Lifecycle Management --
|
||||
|
||||
// XPackIlmPutLifecycle adds or modifies an ilm policy.
|
||||
|
|
4
vendor/github.com/olivere/elastic/v7/docker-compose.yml
generated
vendored
4
vendor/github.com/olivere/elastic/v7/docker-compose.yml
generated
vendored
|
@ -2,7 +2,7 @@ version: '3'
|
|||
|
||||
services:
|
||||
elasticsearch:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.9.2
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.9.3
|
||||
hostname: elasticsearch
|
||||
environment:
|
||||
- cluster.name=elasticsearch
|
||||
|
@ -28,7 +28,7 @@ services:
|
|||
ports:
|
||||
- 9200:9200
|
||||
platinum:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
|
||||
hostname: elasticsearch-platinum
|
||||
environment:
|
||||
- cluster.name=platinum
|
||||
|
|
6
vendor/github.com/olivere/elastic/v7/go.mod
generated
vendored
6
vendor/github.com/olivere/elastic/v7/go.mod
generated
vendored
|
@ -3,8 +3,9 @@ module github.com/olivere/elastic/v7
|
|||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/aws/aws-sdk-go v1.34.13
|
||||
github.com/aws/aws-sdk-go v1.35.20
|
||||
github.com/fortytw2/leaktest v1.3.0
|
||||
github.com/go-sql-driver/mysql v1.5.0 // indirect
|
||||
github.com/google/go-cmp v0.5.2
|
||||
github.com/mailru/easyjson v0.7.6
|
||||
github.com/opentracing/opentracing-go v1.2.0
|
||||
|
@ -12,5 +13,6 @@ require (
|
|||
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.22.4
|
||||
github.com/stretchr/testify v1.5.1 // indirect
|
||||
go.opencensus.io v0.22.5
|
||||
)
|
||||
|
|
186
vendor/github.com/olivere/elastic/v7/indices_delete_index_template.go
generated
vendored
Normal file
186
vendor/github.com/olivere/elastic/v7/indices_delete_index_template.go
generated
vendored
Normal file
|
@ -0,0 +1,186 @@
|
|||
// 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"
|
||||
)
|
||||
|
||||
// IndicesDeleteIndexTemplateService deletes index templates.
|
||||
//
|
||||
// Index templates have changed during in 7.8 update of Elasticsearch.
|
||||
// This service implements the new version (7.8 or later). If you want
|
||||
// the old version, please use the IndicesDeleteTemplateService.
|
||||
//
|
||||
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-delete-template.html
|
||||
// for more details.
|
||||
type IndicesDeleteIndexTemplateService 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
|
||||
}
|
||||
|
||||
// NewIndicesDeleteIndexTemplateService creates a new IndicesDeleteIndexTemplateService.
|
||||
func NewIndicesDeleteIndexTemplateService(client *Client) *IndicesDeleteIndexTemplateService {
|
||||
return &IndicesDeleteIndexTemplateService{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
// Pretty tells Elasticsearch whether to return a formatted JSON response.
|
||||
func (s *IndicesDeleteIndexTemplateService) Pretty(pretty bool) *IndicesDeleteIndexTemplateService {
|
||||
s.pretty = &pretty
|
||||
return s
|
||||
}
|
||||
|
||||
// Human specifies whether human readable values should be returned in
|
||||
// the JSON response, e.g. "7.5mb".
|
||||
func (s *IndicesDeleteIndexTemplateService) Human(human bool) *IndicesDeleteIndexTemplateService {
|
||||
s.human = &human
|
||||
return s
|
||||
}
|
||||
|
||||
// ErrorTrace specifies whether to include the stack trace of returned errors.
|
||||
func (s *IndicesDeleteIndexTemplateService) ErrorTrace(errorTrace bool) *IndicesDeleteIndexTemplateService {
|
||||
s.errorTrace = &errorTrace
|
||||
return s
|
||||
}
|
||||
|
||||
// FilterPath specifies a list of filters used to reduce the response.
|
||||
func (s *IndicesDeleteIndexTemplateService) FilterPath(filterPath ...string) *IndicesDeleteIndexTemplateService {
|
||||
s.filterPath = filterPath
|
||||
return s
|
||||
}
|
||||
|
||||
// Header adds a header to the request.
|
||||
func (s *IndicesDeleteIndexTemplateService) Header(name string, value string) *IndicesDeleteIndexTemplateService {
|
||||
if s.headers == nil {
|
||||
s.headers = http.Header{}
|
||||
}
|
||||
s.headers.Add(name, value)
|
||||
return s
|
||||
}
|
||||
|
||||
// Headers specifies the headers of the request.
|
||||
func (s *IndicesDeleteIndexTemplateService) Headers(headers http.Header) *IndicesDeleteIndexTemplateService {
|
||||
s.headers = headers
|
||||
return s
|
||||
}
|
||||
|
||||
// Name is the name of the template.
|
||||
func (s *IndicesDeleteIndexTemplateService) Name(name string) *IndicesDeleteIndexTemplateService {
|
||||
s.name = name
|
||||
return s
|
||||
}
|
||||
|
||||
// Timeout is an explicit operation timeout.
|
||||
func (s *IndicesDeleteIndexTemplateService) Timeout(timeout string) *IndicesDeleteIndexTemplateService {
|
||||
s.timeout = timeout
|
||||
return s
|
||||
}
|
||||
|
||||
// MasterTimeout specifies the timeout for connection to master.
|
||||
func (s *IndicesDeleteIndexTemplateService) MasterTimeout(masterTimeout string) *IndicesDeleteIndexTemplateService {
|
||||
s.masterTimeout = masterTimeout
|
||||
return s
|
||||
}
|
||||
|
||||
// buildURL builds the URL for the operation.
|
||||
func (s *IndicesDeleteIndexTemplateService) buildURL() (string, url.Values, error) {
|
||||
// Build URL
|
||||
path, err := uritemplates.Expand("/_index_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 *IndicesDeleteIndexTemplateService) 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 *IndicesDeleteIndexTemplateService) Do(ctx context.Context) (*IndicesDeleteIndexTemplateResponse, 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(IndicesDeleteIndexTemplateResponse)
|
||||
if err := s.client.decoder.Decode(res.Body, ret); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// IndicesDeleteIndexTemplateResponse is the response of IndicesDeleteIndexTemplateService.Do.
|
||||
type IndicesDeleteIndexTemplateResponse struct {
|
||||
Acknowledged bool `json:"acknowledged"`
|
||||
ShardsAcknowledged bool `json:"shards_acknowledged"`
|
||||
Index string `json:"index,omitempty"`
|
||||
}
|
10
vendor/github.com/olivere/elastic/v7/indices_delete_template.go
generated
vendored
10
vendor/github.com/olivere/elastic/v7/indices_delete_template.go
generated
vendored
|
@ -14,8 +14,14 @@ import (
|
|||
"github.com/olivere/elastic/v7/uritemplates"
|
||||
)
|
||||
|
||||
// IndicesDeleteTemplateService deletes index templates.
|
||||
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/indices-templates.html.
|
||||
// IndicesDeleteTemplateService deletes templates.
|
||||
//
|
||||
// Index templates have changed during in 7.8 update of Elasticsearch.
|
||||
// This service implements the legacy version (7.7 or lower). If you want
|
||||
// the new version, please use the IndicesDeleteIndexTemplateService.
|
||||
//
|
||||
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-delete-template-v1.html
|
||||
// for more details.
|
||||
type IndicesDeleteTemplateService struct {
|
||||
client *Client
|
||||
|
||||
|
|
16
vendor/github.com/olivere/elastic/v7/indices_exists_template.go
generated
vendored
16
vendor/github.com/olivere/elastic/v7/indices_exists_template.go
generated
vendored
|
@ -26,8 +26,9 @@ type IndicesExistsTemplateService struct {
|
|||
filterPath []string // list of filters used to reduce the response
|
||||
headers http.Header // custom request-level HTTP headers
|
||||
|
||||
name string
|
||||
local *bool
|
||||
name string
|
||||
local *bool
|
||||
masterTimeout string
|
||||
}
|
||||
|
||||
// NewIndicesExistsTemplateService creates a new IndicesExistsTemplateService.
|
||||
|
@ -90,6 +91,12 @@ func (s *IndicesExistsTemplateService) Local(local bool) *IndicesExistsTemplateS
|
|||
return s
|
||||
}
|
||||
|
||||
// MasterTimeout specifies the timeout for connection to master.
|
||||
func (s *IndicesExistsTemplateService) MasterTimeout(masterTimeout string) *IndicesExistsTemplateService {
|
||||
s.masterTimeout = masterTimeout
|
||||
return s
|
||||
}
|
||||
|
||||
// buildURL builds the URL for the operation.
|
||||
func (s *IndicesExistsTemplateService) buildURL() (string, url.Values, error) {
|
||||
// Build URL
|
||||
|
@ -115,7 +122,10 @@ func (s *IndicesExistsTemplateService) buildURL() (string, url.Values, error) {
|
|||
params.Set("filter_path", strings.Join(s.filterPath, ","))
|
||||
}
|
||||
if s.local != nil {
|
||||
params.Set("local", fmt.Sprintf("%v", *s.local))
|
||||
params.Set("local", fmt.Sprint(*s.local))
|
||||
}
|
||||
if s.masterTimeout != "" {
|
||||
params.Set("master_timeout", s.masterTimeout)
|
||||
}
|
||||
return path, params, nil
|
||||
}
|
||||
|
|
214
vendor/github.com/olivere/elastic/v7/indices_get_index_template.go
generated
vendored
Normal file
214
vendor/github.com/olivere/elastic/v7/indices_get_index_template.go
generated
vendored
Normal file
|
@ -0,0 +1,214 @@
|
|||
// 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"
|
||||
)
|
||||
|
||||
// IndicesGetIndexTemplateService returns an index template.
|
||||
//
|
||||
// Index templates have changed during in 7.8 update of Elasticsearch.
|
||||
// This service implements the new version (7.8 or later). If you want
|
||||
// the old version, please use the IndicesGetTemplateService.
|
||||
//
|
||||
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-get-template.html
|
||||
// for more details.
|
||||
type IndicesGetIndexTemplateService 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
|
||||
}
|
||||
|
||||
// NewIndicesGetIndexTemplateService creates a new IndicesGetIndexTemplateService.
|
||||
func NewIndicesGetIndexTemplateService(client *Client) *IndicesGetIndexTemplateService {
|
||||
return &IndicesGetIndexTemplateService{
|
||||
client: client,
|
||||
name: make([]string, 0),
|
||||
}
|
||||
}
|
||||
|
||||
// Pretty tells Elasticsearch whether to return a formatted JSON response.
|
||||
func (s *IndicesGetIndexTemplateService) Pretty(pretty bool) *IndicesGetIndexTemplateService {
|
||||
s.pretty = &pretty
|
||||
return s
|
||||
}
|
||||
|
||||
// Human specifies whether human readable values should be returned in
|
||||
// the JSON response, e.g. "7.5mb".
|
||||
func (s *IndicesGetIndexTemplateService) Human(human bool) *IndicesGetIndexTemplateService {
|
||||
s.human = &human
|
||||
return s
|
||||
}
|
||||
|
||||
// ErrorTrace specifies whether to include the stack trace of returned errors.
|
||||
func (s *IndicesGetIndexTemplateService) ErrorTrace(errorTrace bool) *IndicesGetIndexTemplateService {
|
||||
s.errorTrace = &errorTrace
|
||||
return s
|
||||
}
|
||||
|
||||
// FilterPath specifies a list of filters used to reduce the response.
|
||||
func (s *IndicesGetIndexTemplateService) FilterPath(filterPath ...string) *IndicesGetIndexTemplateService {
|
||||
s.filterPath = filterPath
|
||||
return s
|
||||
}
|
||||
|
||||
// Header adds a header to the request.
|
||||
func (s *IndicesGetIndexTemplateService) Header(name string, value string) *IndicesGetIndexTemplateService {
|
||||
if s.headers == nil {
|
||||
s.headers = http.Header{}
|
||||
}
|
||||
s.headers.Add(name, value)
|
||||
return s
|
||||
}
|
||||
|
||||
// Headers specifies the headers of the request.
|
||||
func (s *IndicesGetIndexTemplateService) Headers(headers http.Header) *IndicesGetIndexTemplateService {
|
||||
s.headers = headers
|
||||
return s
|
||||
}
|
||||
|
||||
// Name is the name of the index template.
|
||||
func (s *IndicesGetIndexTemplateService) Name(name ...string) *IndicesGetIndexTemplateService {
|
||||
s.name = append(s.name, name...)
|
||||
return s
|
||||
}
|
||||
|
||||
// FlatSettings is returns settings in flat format (default: false).
|
||||
func (s *IndicesGetIndexTemplateService) FlatSettings(flatSettings bool) *IndicesGetIndexTemplateService {
|
||||
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 *IndicesGetIndexTemplateService) Local(local bool) *IndicesGetIndexTemplateService {
|
||||
s.local = &local
|
||||
return s
|
||||
}
|
||||
|
||||
// MasterTimeout specifies the timeout for connection to master.
|
||||
func (s *IndicesGetIndexTemplateService) MasterTimeout(masterTimeout string) *IndicesGetIndexTemplateService {
|
||||
s.masterTimeout = masterTimeout
|
||||
return s
|
||||
}
|
||||
|
||||
// buildURL builds the URL for the operation.
|
||||
func (s *IndicesGetIndexTemplateService) buildURL() (string, url.Values, error) {
|
||||
// Build URL
|
||||
var err error
|
||||
var path string
|
||||
if len(s.name) > 0 {
|
||||
path, err = uritemplates.Expand("/_index_template/{name}", map[string]string{
|
||||
"name": strings.Join(s.name, ","),
|
||||
})
|
||||
} else {
|
||||
path = "/_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 *IndicesGetIndexTemplateService) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Do executes the operation.
|
||||
func (s *IndicesGetIndexTemplateService) Do(ctx context.Context) (*IndicesGetIndexTemplateResponse, 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 *IndicesGetIndexTemplateResponse
|
||||
if err := s.client.decoder.Decode(res.Body, &ret); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// IndicesGetIndexTemplateResponse is the response of IndicesGetIndexTemplateService.Do.
|
||||
type IndicesGetIndexTemplateResponse struct {
|
||||
IndexTemplates []IndicesGetIndexTemplates `json:"index_templates"`
|
||||
}
|
||||
|
||||
type IndicesGetIndexTemplates struct {
|
||||
Name string `json:"name"`
|
||||
IndexTemplate *IndicesGetIndexTemplate `json:"index_template"`
|
||||
}
|
||||
|
||||
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"`
|
||||
}
|
||||
|
||||
type IndicesGetIndexTemplateData struct {
|
||||
Settings map[string]interface{} `json:"settings,omitempty"`
|
||||
Mappings map[string]interface{} `json:"mappings,omitempty"`
|
||||
Aliases map[string]interface{} `json:"aliases,omitempty"`
|
||||
}
|
10
vendor/github.com/olivere/elastic/v7/indices_get_template.go
generated
vendored
10
vendor/github.com/olivere/elastic/v7/indices_get_template.go
generated
vendored
|
@ -14,8 +14,14 @@ import (
|
|||
"github.com/olivere/elastic/v7/uritemplates"
|
||||
)
|
||||
|
||||
// IndicesGetTemplateService returns an index template.
|
||||
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/indices-templates.html.
|
||||
// IndicesGetTemplateService returns an index template (v1).
|
||||
//
|
||||
// Index templates have changed during in 7.8 update of Elasticsearch.
|
||||
// This service implements the legacy version (7.7 or lower). If you want
|
||||
// the new version, please use the IndicesGetIndexTemplateService.
|
||||
//
|
||||
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-get-template-v1.html
|
||||
// for more details.
|
||||
type IndicesGetTemplateService struct {
|
||||
client *Client
|
||||
|
||||
|
|
226
vendor/github.com/olivere/elastic/v7/indices_put_index_template.go
generated
vendored
Normal file
226
vendor/github.com/olivere/elastic/v7/indices_put_index_template.go
generated
vendored
Normal file
|
@ -0,0 +1,226 @@
|
|||
// 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"
|
||||
)
|
||||
|
||||
// IndicesPutIndexTemplateService creates or updates index templates.
|
||||
//
|
||||
// Index templates have changed during in 7.8 update of Elasticsearch.
|
||||
// This service implements the new version (7.8 or higher) for managing
|
||||
// index templates. If you want the v1/legacy version, please see e.g.
|
||||
// IndicesPutTemplateService and friends.
|
||||
//
|
||||
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-put-template.html
|
||||
// for more details on this API.
|
||||
type IndicesPutIndexTemplateService 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
|
||||
}
|
||||
|
||||
// NewIndicesPutIndexTemplateService creates a new IndicesPutIndexTemplateService.
|
||||
func NewIndicesPutIndexTemplateService(client *Client) *IndicesPutIndexTemplateService {
|
||||
return &IndicesPutIndexTemplateService{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
// Pretty tells Elasticsearch whether to return a formatted JSON response.
|
||||
func (s *IndicesPutIndexTemplateService) Pretty(pretty bool) *IndicesPutIndexTemplateService {
|
||||
s.pretty = &pretty
|
||||
return s
|
||||
}
|
||||
|
||||
// Human specifies whether human readable values should be returned in
|
||||
// the JSON response, e.g. "7.5mb".
|
||||
func (s *IndicesPutIndexTemplateService) Human(human bool) *IndicesPutIndexTemplateService {
|
||||
s.human = &human
|
||||
return s
|
||||
}
|
||||
|
||||
// ErrorTrace specifies whether to include the stack trace of returned errors.
|
||||
func (s *IndicesPutIndexTemplateService) ErrorTrace(errorTrace bool) *IndicesPutIndexTemplateService {
|
||||
s.errorTrace = &errorTrace
|
||||
return s
|
||||
}
|
||||
|
||||
// FilterPath specifies a list of filters used to reduce the response.
|
||||
func (s *IndicesPutIndexTemplateService) FilterPath(filterPath ...string) *IndicesPutIndexTemplateService {
|
||||
s.filterPath = filterPath
|
||||
return s
|
||||
}
|
||||
|
||||
// Header adds a header to the request.
|
||||
func (s *IndicesPutIndexTemplateService) Header(name string, value string) *IndicesPutIndexTemplateService {
|
||||
if s.headers == nil {
|
||||
s.headers = http.Header{}
|
||||
}
|
||||
s.headers.Add(name, value)
|
||||
return s
|
||||
}
|
||||
|
||||
// Headers specifies the headers of the request.
|
||||
func (s *IndicesPutIndexTemplateService) Headers(headers http.Header) *IndicesPutIndexTemplateService {
|
||||
s.headers = headers
|
||||
return s
|
||||
}
|
||||
|
||||
// Name is the name of the index template.
|
||||
func (s *IndicesPutIndexTemplateService) Name(name string) *IndicesPutIndexTemplateService {
|
||||
s.name = name
|
||||
return s
|
||||
}
|
||||
|
||||
// Create indicates whether the index template should only be added if
|
||||
// new or can also replace an existing one.
|
||||
func (s *IndicesPutIndexTemplateService) Create(create bool) *IndicesPutIndexTemplateService {
|
||||
s.create = &create
|
||||
return s
|
||||
}
|
||||
|
||||
// Cause is the user-defined reason for creating/updating the the index template.
|
||||
func (s *IndicesPutIndexTemplateService) Cause(cause string) *IndicesPutIndexTemplateService {
|
||||
s.cause = cause
|
||||
return s
|
||||
}
|
||||
|
||||
// MasterTimeout specifies the timeout for connection to master.
|
||||
func (s *IndicesPutIndexTemplateService) MasterTimeout(masterTimeout string) *IndicesPutIndexTemplateService {
|
||||
s.masterTimeout = masterTimeout
|
||||
return s
|
||||
}
|
||||
|
||||
// BodyJson is the index template definition as a JSON serializable
|
||||
// type, e.g. map[string]interface{}.
|
||||
func (s *IndicesPutIndexTemplateService) BodyJson(body interface{}) *IndicesPutIndexTemplateService {
|
||||
s.bodyJson = body
|
||||
return s
|
||||
}
|
||||
|
||||
// BodyString is the index template definition as a raw string.
|
||||
func (s *IndicesPutIndexTemplateService) BodyString(body string) *IndicesPutIndexTemplateService {
|
||||
s.bodyString = body
|
||||
return s
|
||||
}
|
||||
|
||||
// buildURL builds the URL for the operation.
|
||||
func (s *IndicesPutIndexTemplateService) buildURL() (string, url.Values, error) {
|
||||
// Build URL
|
||||
path, err := uritemplates.Expand("/_index_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 *IndicesPutIndexTemplateService) 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 *IndicesPutIndexTemplateService) Do(ctx context.Context) (*IndicesPutIndexTemplateResponse, 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(IndicesPutIndexTemplateResponse)
|
||||
if err := s.client.decoder.Decode(res.Body, ret); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// IndicesPutIndexTemplateResponse is the response of IndicesPutIndexTemplateService.Do.
|
||||
type IndicesPutIndexTemplateResponse struct {
|
||||
Acknowledged bool `json:"acknowledged"`
|
||||
ShardsAcknowledged bool `json:"shards_acknowledged"`
|
||||
Index string `json:"index,omitempty"`
|
||||
}
|
10
vendor/github.com/olivere/elastic/v7/indices_put_template.go
generated
vendored
10
vendor/github.com/olivere/elastic/v7/indices_put_template.go
generated
vendored
|
@ -14,8 +14,14 @@ import (
|
|||
"github.com/olivere/elastic/v7/uritemplates"
|
||||
)
|
||||
|
||||
// IndicesPutTemplateService creates or updates index mappings.
|
||||
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/indices-templates.html.
|
||||
// IndicesPutTemplateService creates or updates templates.
|
||||
//
|
||||
// Index templates have changed during in 7.8 update of Elasticsearch.
|
||||
// This service implements the legacy version (7.7 or lower). If you want
|
||||
// the new version, please use the IndicesPutIndexTemplateService.
|
||||
//
|
||||
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.9/indices-templates-v1.html
|
||||
// for more details.
|
||||
type IndicesPutTemplateService struct {
|
||||
client *Client
|
||||
|
||||
|
|
154
vendor/github.com/olivere/elastic/v7/xpack_async_search_delete.go
generated
vendored
Normal file
154
vendor/github.com/olivere/elastic/v7/xpack_async_search_delete.go
generated
vendored
Normal file
|
@ -0,0 +1,154 @@
|
|||
// 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"
|
||||
)
|
||||
|
||||
// XPackAsyncSearchDelete allows removing an asynchronous search result,
|
||||
// previously being started with XPackAsyncSearchSubmit service.
|
||||
//
|
||||
// For more details, see the documentation at
|
||||
// https://www.elastic.co/guide/en/elasticsearch/reference/7.9/async-search.html
|
||||
type XPackAsyncSearchDelete 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
|
||||
|
||||
// ID of asynchronous search as returned by XPackAsyncSearchSubmit.Do.
|
||||
id string
|
||||
}
|
||||
|
||||
// NewXPackAsyncSearchDelete creates a new XPackAsyncSearchDelete.
|
||||
func NewXPackAsyncSearchDelete(client *Client) *XPackAsyncSearchDelete {
|
||||
return &XPackAsyncSearchDelete{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
// Pretty tells Elasticsearch whether to return a formatted JSON response.
|
||||
func (s *XPackAsyncSearchDelete) Pretty(pretty bool) *XPackAsyncSearchDelete {
|
||||
s.pretty = &pretty
|
||||
return s
|
||||
}
|
||||
|
||||
// Human specifies whether human readable values should be returned in
|
||||
// the JSON response, e.g. "7.5mb".
|
||||
func (s *XPackAsyncSearchDelete) Human(human bool) *XPackAsyncSearchDelete {
|
||||
s.human = &human
|
||||
return s
|
||||
}
|
||||
|
||||
// ErrorTrace specifies whether to include the stack trace of returned errors.
|
||||
func (s *XPackAsyncSearchDelete) ErrorTrace(errorTrace bool) *XPackAsyncSearchDelete {
|
||||
s.errorTrace = &errorTrace
|
||||
return s
|
||||
}
|
||||
|
||||
// FilterPath specifies a list of filters used to reduce the response.
|
||||
func (s *XPackAsyncSearchDelete) FilterPath(filterPath ...string) *XPackAsyncSearchDelete {
|
||||
s.filterPath = filterPath
|
||||
return s
|
||||
}
|
||||
|
||||
// Header adds a header to the request.
|
||||
func (s *XPackAsyncSearchDelete) Header(name string, value string) *XPackAsyncSearchDelete {
|
||||
if s.headers == nil {
|
||||
s.headers = http.Header{}
|
||||
}
|
||||
s.headers.Add(name, value)
|
||||
return s
|
||||
}
|
||||
|
||||
// Headers specifies the headers of the request.
|
||||
func (s *XPackAsyncSearchDelete) Headers(headers http.Header) *XPackAsyncSearchDelete {
|
||||
s.headers = headers
|
||||
return s
|
||||
}
|
||||
|
||||
// ID of the asynchronous search.
|
||||
func (s *XPackAsyncSearchDelete) ID(id string) *XPackAsyncSearchDelete {
|
||||
s.id = id
|
||||
return s
|
||||
}
|
||||
|
||||
// buildURL builds the URL for the operation.
|
||||
func (s *XPackAsyncSearchDelete) buildURL() (string, url.Values, error) {
|
||||
path := fmt.Sprintf("/_async_search/%s", url.PathEscape(s.id))
|
||||
|
||||
// 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 *XPackAsyncSearchDelete) Validate() error {
|
||||
var invalid []string
|
||||
if s.id == "" {
|
||||
invalid = append(invalid, "ID")
|
||||
}
|
||||
if len(invalid) > 0 {
|
||||
return fmt.Errorf("missing required fields: %v", invalid)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Do executes the operation.
|
||||
func (s *XPackAsyncSearchDelete) Do(ctx context.Context) (*XPackAsyncSearchDeleteResponse, 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(XPackAsyncSearchDeleteResponse)
|
||||
if err := s.client.decoder.Decode(res.Body, ret); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// XPackAsyncSearchDeleteResponse is the outcome of calling XPackAsyncSearchDelete.Do.
|
||||
type XPackAsyncSearchDeleteResponse struct {
|
||||
Acknowledged bool `json:"acknowledged"`
|
||||
}
|
178
vendor/github.com/olivere/elastic/v7/xpack_async_search_get.go
generated
vendored
Normal file
178
vendor/github.com/olivere/elastic/v7/xpack_async_search_get.go
generated
vendored
Normal file
|
@ -0,0 +1,178 @@
|
|||
// 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"
|
||||
)
|
||||
|
||||
// XPackAsyncSearchGet allows retrieving an asynchronous search result,
|
||||
// previously being started with XPackAsyncSearchSubmit service.
|
||||
//
|
||||
// For more details, see the documentation at
|
||||
// https://www.elastic.co/guide/en/elasticsearch/reference/7.9/async-search.html
|
||||
type XPackAsyncSearchGet 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
|
||||
|
||||
// ID of asynchronous search as returned by XPackAsyncSearchSubmit.Do.
|
||||
id string
|
||||
// waitForCompletionTimeout is the duration the call should wait for a result
|
||||
// before timing out. The default is 1 second.
|
||||
waitForCompletionTimeout string
|
||||
// keepAlive asks Elasticsearch to keep the ID and its results even
|
||||
// after the search has been completed.
|
||||
keepAlive string
|
||||
}
|
||||
|
||||
// NewXPackAsyncSearchGet creates a new XPackAsyncSearchGet.
|
||||
func NewXPackAsyncSearchGet(client *Client) *XPackAsyncSearchGet {
|
||||
return &XPackAsyncSearchGet{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
// Pretty tells Elasticsearch whether to return a formatted JSON response.
|
||||
func (s *XPackAsyncSearchGet) Pretty(pretty bool) *XPackAsyncSearchGet {
|
||||
s.pretty = &pretty
|
||||
return s
|
||||
}
|
||||
|
||||
// Human specifies whether human readable values should be returned in
|
||||
// the JSON response, e.g. "7.5mb".
|
||||
func (s *XPackAsyncSearchGet) Human(human bool) *XPackAsyncSearchGet {
|
||||
s.human = &human
|
||||
return s
|
||||
}
|
||||
|
||||
// ErrorTrace specifies whether to include the stack trace of returned errors.
|
||||
func (s *XPackAsyncSearchGet) ErrorTrace(errorTrace bool) *XPackAsyncSearchGet {
|
||||
s.errorTrace = &errorTrace
|
||||
return s
|
||||
}
|
||||
|
||||
// FilterPath specifies a list of filters used to reduce the response.
|
||||
func (s *XPackAsyncSearchGet) FilterPath(filterPath ...string) *XPackAsyncSearchGet {
|
||||
s.filterPath = filterPath
|
||||
return s
|
||||
}
|
||||
|
||||
// Header adds a header to the request.
|
||||
func (s *XPackAsyncSearchGet) Header(name string, value string) *XPackAsyncSearchGet {
|
||||
if s.headers == nil {
|
||||
s.headers = http.Header{}
|
||||
}
|
||||
s.headers.Add(name, value)
|
||||
return s
|
||||
}
|
||||
|
||||
// Headers specifies the headers of the request.
|
||||
func (s *XPackAsyncSearchGet) Headers(headers http.Header) *XPackAsyncSearchGet {
|
||||
s.headers = headers
|
||||
return s
|
||||
}
|
||||
|
||||
// ID of the asynchronous search.
|
||||
func (s *XPackAsyncSearchGet) ID(id string) *XPackAsyncSearchGet {
|
||||
s.id = id
|
||||
return s
|
||||
}
|
||||
|
||||
// WaitForCompletionTimeout specifies the time the service waits for retrieving
|
||||
// a complete result. If the timeout expires, you'll get the current results which
|
||||
// might not be complete.
|
||||
func (s *XPackAsyncSearchGet) WaitForCompletionTimeout(waitForCompletionTimeout string) *XPackAsyncSearchGet {
|
||||
s.waitForCompletionTimeout = waitForCompletionTimeout
|
||||
return s
|
||||
}
|
||||
|
||||
// KeepAlive is the time the search results are kept by Elasticsearch before
|
||||
// being garbage collected.
|
||||
func (s *XPackAsyncSearchGet) KeepAlive(keepAlive string) *XPackAsyncSearchGet {
|
||||
s.keepAlive = keepAlive
|
||||
return s
|
||||
}
|
||||
|
||||
// buildURL builds the URL for the operation.
|
||||
func (s *XPackAsyncSearchGet) buildURL() (string, url.Values, error) {
|
||||
path := fmt.Sprintf("/_async_search/%s", url.PathEscape(s.id))
|
||||
|
||||
// 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.waitForCompletionTimeout != "" {
|
||||
params.Set("wait_for_completion_timeout", s.waitForCompletionTimeout)
|
||||
}
|
||||
if s.keepAlive != "" {
|
||||
params.Set("keep_alive", s.keepAlive)
|
||||
}
|
||||
return path, params, nil
|
||||
}
|
||||
|
||||
// Validate checks if the operation is valid.
|
||||
func (s *XPackAsyncSearchGet) Validate() error {
|
||||
var invalid []string
|
||||
if s.id == "" {
|
||||
invalid = append(invalid, "ID")
|
||||
}
|
||||
if len(invalid) > 0 {
|
||||
return fmt.Errorf("missing required fields: %v", invalid)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Do executes the operation.
|
||||
func (s *XPackAsyncSearchGet) Do(ctx context.Context) (*XPackAsyncSearchResult, 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 := new(XPackAsyncSearchResult)
|
||||
if err := s.client.decoder.Decode(res.Body, ret); err != nil {
|
||||
ret.Header = res.Header
|
||||
return nil, err
|
||||
}
|
||||
ret.Header = res.Header
|
||||
return ret, nil
|
||||
}
|
718
vendor/github.com/olivere/elastic/v7/xpack_async_search_submit.go
generated
vendored
Normal file
718
vendor/github.com/olivere/elastic/v7/xpack_async_search_submit.go
generated
vendored
Normal file
|
@ -0,0 +1,718 @@
|
|||
// 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"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/olivere/elastic/v7/uritemplates"
|
||||
)
|
||||
|
||||
// XPackAsyncSearchSubmit is an XPack API for asynchronously
|
||||
// searching for documents in Elasticsearch.
|
||||
//
|
||||
// For more details, see the documentation at
|
||||
// https://www.elastic.co/guide/en/elasticsearch/reference/7.9/async-search.html
|
||||
type XPackAsyncSearchSubmit 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
|
||||
|
||||
searchSource *SearchSource // q
|
||||
source interface{}
|
||||
searchType string // search_type
|
||||
index []string
|
||||
typ []string
|
||||
routing string // routing
|
||||
preference string // preference
|
||||
requestCache *bool // request_cache
|
||||
ignoreUnavailable *bool // ignore_unavailable
|
||||
ignoreThrottled *bool // ignore_throttled
|
||||
allowNoIndices *bool // allow_no_indices
|
||||
expandWildcards string // expand_wildcards
|
||||
lenient *bool // lenient
|
||||
maxResponseSize int64
|
||||
allowPartialSearchResults *bool // allow_partial_search_results
|
||||
typedKeys *bool // typed_keys
|
||||
seqNoPrimaryTerm *bool // seq_no_primary_term
|
||||
batchedReduceSize *int // batched_reduce_size
|
||||
maxConcurrentShardRequests *int // max_concurrent_shard_requests
|
||||
preFilterShardSize *int // pre_filter_shard_size
|
||||
restTotalHitsAsInt *bool // rest_total_hits_as_int
|
||||
|
||||
ccsMinimizeRoundtrips *bool // ccs_minimize_roundtrips
|
||||
|
||||
waitForCompletionTimeout string // e.g. "1s"
|
||||
keepOnCompletion *bool
|
||||
keepAlive string // e.g. "1h"
|
||||
}
|
||||
|
||||
// NewXPackAsyncSearchSubmit creates a new service for asynchronously
|
||||
// searching in Elasticsearch.
|
||||
func NewXPackAsyncSearchSubmit(client *Client) *XPackAsyncSearchSubmit {
|
||||
builder := &XPackAsyncSearchSubmit{
|
||||
client: client,
|
||||
searchSource: NewSearchSource(),
|
||||
}
|
||||
return builder
|
||||
}
|
||||
|
||||
// Pretty tells Elasticsearch whether to return a formatted JSON response.
|
||||
func (s *XPackAsyncSearchSubmit) Pretty(pretty bool) *XPackAsyncSearchSubmit {
|
||||
s.pretty = &pretty
|
||||
return s
|
||||
}
|
||||
|
||||
// Human specifies whether human readable values should be returned in
|
||||
// the JSON response, e.g. "7.5mb".
|
||||
func (s *XPackAsyncSearchSubmit) Human(human bool) *XPackAsyncSearchSubmit {
|
||||
s.human = &human
|
||||
return s
|
||||
}
|
||||
|
||||
// ErrorTrace specifies whether to include the stack trace of returned errors.
|
||||
func (s *XPackAsyncSearchSubmit) ErrorTrace(errorTrace bool) *XPackAsyncSearchSubmit {
|
||||
s.errorTrace = &errorTrace
|
||||
return s
|
||||
}
|
||||
|
||||
// FilterPath specifies a list of filters used to reduce the response.
|
||||
func (s *XPackAsyncSearchSubmit) FilterPath(filterPath ...string) *XPackAsyncSearchSubmit {
|
||||
s.filterPath = filterPath
|
||||
return s
|
||||
}
|
||||
|
||||
// Header adds a header to the request.
|
||||
func (s *XPackAsyncSearchSubmit) Header(name string, value string) *XPackAsyncSearchSubmit {
|
||||
if s.headers == nil {
|
||||
s.headers = http.Header{}
|
||||
}
|
||||
s.headers.Add(name, value)
|
||||
return s
|
||||
}
|
||||
|
||||
// Headers specifies the headers of the request.
|
||||
func (s *XPackAsyncSearchSubmit) Headers(headers http.Header) *XPackAsyncSearchSubmit {
|
||||
s.headers = headers
|
||||
return s
|
||||
}
|
||||
|
||||
// SearchSource sets the search source builder to use with this service.
|
||||
func (s *XPackAsyncSearchSubmit) SearchSource(searchSource *SearchSource) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = searchSource
|
||||
if s.searchSource == nil {
|
||||
s.searchSource = NewSearchSource()
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Source allows the user to set the request body manually without using
|
||||
// any of the structs and interfaces in Elastic.
|
||||
func (s *XPackAsyncSearchSubmit) Source(source interface{}) *XPackAsyncSearchSubmit {
|
||||
s.source = source
|
||||
return s
|
||||
}
|
||||
|
||||
// Index sets the names of the indices to use for search.
|
||||
func (s *XPackAsyncSearchSubmit) Index(index ...string) *XPackAsyncSearchSubmit {
|
||||
s.index = append(s.index, index...)
|
||||
return s
|
||||
}
|
||||
|
||||
// Type adds search restrictions for a list of types.
|
||||
//
|
||||
// Deprecated: Types are in the process of being removed. Instead of using a type, prefer to
|
||||
// filter on a field on the document.
|
||||
func (s *XPackAsyncSearchSubmit) Type(typ ...string) *XPackAsyncSearchSubmit {
|
||||
s.typ = append(s.typ, typ...)
|
||||
return s
|
||||
}
|
||||
|
||||
// Timeout sets the timeout to use, e.g. "1s" or "1000ms".
|
||||
func (s *XPackAsyncSearchSubmit) Timeout(timeout string) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.Timeout(timeout)
|
||||
return s
|
||||
}
|
||||
|
||||
// Profile sets the Profile API flag on the search source.
|
||||
// When enabled, a search executed by this service will return query
|
||||
// profiling data.
|
||||
func (s *XPackAsyncSearchSubmit) Profile(profile bool) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.Profile(profile)
|
||||
return s
|
||||
}
|
||||
|
||||
// Collapse adds field collapsing.
|
||||
func (s *XPackAsyncSearchSubmit) Collapse(collapse *CollapseBuilder) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.Collapse(collapse)
|
||||
return s
|
||||
}
|
||||
|
||||
// TimeoutInMillis sets the timeout in milliseconds.
|
||||
func (s *XPackAsyncSearchSubmit) TimeoutInMillis(timeoutInMillis int) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.TimeoutInMillis(timeoutInMillis)
|
||||
return s
|
||||
}
|
||||
|
||||
// TerminateAfter specifies the maximum number of documents to collect for
|
||||
// each shard, upon reaching which the query execution will terminate early.
|
||||
func (s *XPackAsyncSearchSubmit) TerminateAfter(terminateAfter int) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.TerminateAfter(terminateAfter)
|
||||
return s
|
||||
}
|
||||
|
||||
// SearchType sets the search operation type. Valid values are:
|
||||
// "dfs_query_then_fetch" and "query_then_fetch".
|
||||
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/search-request-search-type.html
|
||||
// for details.
|
||||
func (s *XPackAsyncSearchSubmit) SearchType(searchType string) *XPackAsyncSearchSubmit {
|
||||
s.searchType = searchType
|
||||
return s
|
||||
}
|
||||
|
||||
// Routing is a list of specific routing values to control the shards
|
||||
// the search will be executed on.
|
||||
func (s *XPackAsyncSearchSubmit) Routing(routings ...string) *XPackAsyncSearchSubmit {
|
||||
s.routing = strings.Join(routings, ",")
|
||||
return s
|
||||
}
|
||||
|
||||
// Preference sets the preference to execute the search. Defaults to
|
||||
// randomize across shards ("random"). Can be set to "_local" to prefer
|
||||
// local shards, "_primary" to execute on primary shards only,
|
||||
// or a custom value which guarantees that the same order will be used
|
||||
// across different requests.
|
||||
func (s *XPackAsyncSearchSubmit) Preference(preference string) *XPackAsyncSearchSubmit {
|
||||
s.preference = preference
|
||||
return s
|
||||
}
|
||||
|
||||
// RequestCache indicates whether the cache should be used for this
|
||||
// request or not, defaults to index level setting.
|
||||
func (s *XPackAsyncSearchSubmit) RequestCache(requestCache bool) *XPackAsyncSearchSubmit {
|
||||
s.requestCache = &requestCache
|
||||
return s
|
||||
}
|
||||
|
||||
// Query sets the query to perform, e.g. MatchAllQuery.
|
||||
func (s *XPackAsyncSearchSubmit) Query(query Query) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.Query(query)
|
||||
return s
|
||||
}
|
||||
|
||||
// PostFilter will be executed after the query has been executed and
|
||||
// only affects the search hits, not the aggregations.
|
||||
// This filter is always executed as the last filtering mechanism.
|
||||
func (s *XPackAsyncSearchSubmit) PostFilter(postFilter Query) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.PostFilter(postFilter)
|
||||
return s
|
||||
}
|
||||
|
||||
// FetchSource indicates whether the response should contain the stored
|
||||
// _source for every hit.
|
||||
func (s *XPackAsyncSearchSubmit) FetchSource(fetchSource bool) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.FetchSource(fetchSource)
|
||||
return s
|
||||
}
|
||||
|
||||
// FetchSourceContext indicates how the _source should be fetched.
|
||||
func (s *XPackAsyncSearchSubmit) FetchSourceContext(fetchSourceContext *FetchSourceContext) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.FetchSourceContext(fetchSourceContext)
|
||||
return s
|
||||
}
|
||||
|
||||
// Highlight adds highlighting to the search.
|
||||
func (s *XPackAsyncSearchSubmit) Highlight(highlight *Highlight) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.Highlight(highlight)
|
||||
return s
|
||||
}
|
||||
|
||||
// GlobalSuggestText defines the global text to use with all suggesters.
|
||||
// This avoids repetition.
|
||||
func (s *XPackAsyncSearchSubmit) GlobalSuggestText(globalText string) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.GlobalSuggestText(globalText)
|
||||
return s
|
||||
}
|
||||
|
||||
// Suggester adds a suggester to the search.
|
||||
func (s *XPackAsyncSearchSubmit) Suggester(suggester Suggester) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.Suggester(suggester)
|
||||
return s
|
||||
}
|
||||
|
||||
// Aggregation adds an aggreation to perform as part of the search.
|
||||
func (s *XPackAsyncSearchSubmit) Aggregation(name string, aggregation Aggregation) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.Aggregation(name, aggregation)
|
||||
return s
|
||||
}
|
||||
|
||||
// MinScore sets the minimum score below which docs will be filtered out.
|
||||
func (s *XPackAsyncSearchSubmit) MinScore(minScore float64) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.MinScore(minScore)
|
||||
return s
|
||||
}
|
||||
|
||||
// From index to start the search from. Defaults to 0.
|
||||
func (s *XPackAsyncSearchSubmit) From(from int) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.From(from)
|
||||
return s
|
||||
}
|
||||
|
||||
// Size is the number of search hits to return. Defaults to 10.
|
||||
func (s *XPackAsyncSearchSubmit) Size(size int) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.Size(size)
|
||||
return s
|
||||
}
|
||||
|
||||
// Explain indicates whether each search hit should be returned with
|
||||
// an explanation of the hit (ranking).
|
||||
func (s *XPackAsyncSearchSubmit) Explain(explain bool) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.Explain(explain)
|
||||
return s
|
||||
}
|
||||
|
||||
// Version indicates whether each search hit should be returned with
|
||||
// a version associated to it.
|
||||
func (s *XPackAsyncSearchSubmit) Version(version bool) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.Version(version)
|
||||
return s
|
||||
}
|
||||
|
||||
// Sort adds a sort order.
|
||||
func (s *XPackAsyncSearchSubmit) Sort(field string, ascending bool) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.Sort(field, ascending)
|
||||
return s
|
||||
}
|
||||
|
||||
// SortWithInfo adds a sort order.
|
||||
func (s *XPackAsyncSearchSubmit) SortWithInfo(info SortInfo) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.SortWithInfo(info)
|
||||
return s
|
||||
}
|
||||
|
||||
// SortBy adds a sort order.
|
||||
func (s *XPackAsyncSearchSubmit) SortBy(sorter ...Sorter) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.SortBy(sorter...)
|
||||
return s
|
||||
}
|
||||
|
||||
// DocvalueField adds a single field to load from the field data cache
|
||||
// and return as part of the search.
|
||||
func (s *XPackAsyncSearchSubmit) DocvalueField(docvalueField string) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.DocvalueField(docvalueField)
|
||||
return s
|
||||
}
|
||||
|
||||
// DocvalueFieldWithFormat adds a single field to load from the field data cache
|
||||
// and return as part of the search.
|
||||
func (s *XPackAsyncSearchSubmit) DocvalueFieldWithFormat(docvalueField DocvalueField) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.DocvalueFieldWithFormat(docvalueField)
|
||||
return s
|
||||
}
|
||||
|
||||
// DocvalueFields adds one or more fields to load from the field data cache
|
||||
// and return as part of the search.
|
||||
func (s *XPackAsyncSearchSubmit) DocvalueFields(docvalueFields ...string) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.DocvalueFields(docvalueFields...)
|
||||
return s
|
||||
}
|
||||
|
||||
// DocvalueFieldsWithFormat adds one or more fields to load from the field data cache
|
||||
// and return as part of the search.
|
||||
func (s *XPackAsyncSearchSubmit) DocvalueFieldsWithFormat(docvalueFields ...DocvalueField) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.DocvalueFieldsWithFormat(docvalueFields...)
|
||||
return s
|
||||
}
|
||||
|
||||
// NoStoredFields indicates that no stored fields should be loaded, resulting in only
|
||||
// id and type to be returned per field.
|
||||
func (s *XPackAsyncSearchSubmit) NoStoredFields() *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.NoStoredFields()
|
||||
return s
|
||||
}
|
||||
|
||||
// StoredField adds a single field to load and return (note, must be stored) as
|
||||
// part of the search request. If none are specified, the source of the
|
||||
// document will be returned.
|
||||
func (s *XPackAsyncSearchSubmit) StoredField(fieldName string) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.StoredField(fieldName)
|
||||
return s
|
||||
}
|
||||
|
||||
// StoredFields sets the fields to load and return as part of the search request.
|
||||
// If none are specified, the source of the document will be returned.
|
||||
func (s *XPackAsyncSearchSubmit) StoredFields(fields ...string) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.StoredFields(fields...)
|
||||
return s
|
||||
}
|
||||
|
||||
// TrackScores is applied when sorting and controls if scores will be
|
||||
// tracked as well. Defaults to false.
|
||||
func (s *XPackAsyncSearchSubmit) TrackScores(trackScores bool) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.TrackScores(trackScores)
|
||||
return s
|
||||
}
|
||||
|
||||
// TrackTotalHits controls if the total hit count for the query should be tracked.
|
||||
//
|
||||
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.1/search-request-track-total-hits.html
|
||||
// for details.
|
||||
func (s *XPackAsyncSearchSubmit) TrackTotalHits(trackTotalHits interface{}) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.TrackTotalHits(trackTotalHits)
|
||||
return s
|
||||
}
|
||||
|
||||
// SearchAfter allows a different form of pagination by using a live cursor,
|
||||
// using the results of the previous page to help the retrieval of the next.
|
||||
//
|
||||
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/search-request-search-after.html
|
||||
func (s *XPackAsyncSearchSubmit) SearchAfter(sortValues ...interface{}) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.SearchAfter(sortValues...)
|
||||
return s
|
||||
}
|
||||
|
||||
// DefaultRescoreWindowSize sets the rescore window size for rescores
|
||||
// that don't specify their window.
|
||||
func (s *XPackAsyncSearchSubmit) DefaultRescoreWindowSize(defaultRescoreWindowSize int) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.DefaultRescoreWindowSize(defaultRescoreWindowSize)
|
||||
return s
|
||||
}
|
||||
|
||||
// Rescorer adds a rescorer to the search.
|
||||
func (s *XPackAsyncSearchSubmit) Rescorer(rescore *Rescore) *XPackAsyncSearchSubmit {
|
||||
s.searchSource = s.searchSource.Rescorer(rescore)
|
||||
return s
|
||||
}
|
||||
|
||||
// IgnoreUnavailable indicates whether the specified concrete indices
|
||||
// should be ignored when unavailable (missing or closed).
|
||||
func (s *XPackAsyncSearchSubmit) IgnoreUnavailable(ignoreUnavailable bool) *XPackAsyncSearchSubmit {
|
||||
s.ignoreUnavailable = &ignoreUnavailable
|
||||
return s
|
||||
}
|
||||
|
||||
// IgnoreThrottled indicates whether specified concrete, expanded or aliased
|
||||
// indices should be ignored when throttled.
|
||||
func (s *XPackAsyncSearchSubmit) IgnoreThrottled(ignoreThrottled bool) *XPackAsyncSearchSubmit {
|
||||
s.ignoreThrottled = &ignoreThrottled
|
||||
return s
|
||||
}
|
||||
|
||||
// AllowNoIndices indicates whether to ignore if a wildcard indices
|
||||
// expression resolves into no concrete indices. (This includes `_all` string
|
||||
// or when no indices have been specified).
|
||||
func (s *XPackAsyncSearchSubmit) AllowNoIndices(allowNoIndices bool) *XPackAsyncSearchSubmit {
|
||||
s.allowNoIndices = &allowNoIndices
|
||||
return s
|
||||
}
|
||||
|
||||
// ExpandWildcards indicates whether to expand wildcard expression to
|
||||
// concrete indices that are open, closed or both.
|
||||
func (s *XPackAsyncSearchSubmit) ExpandWildcards(expandWildcards string) *XPackAsyncSearchSubmit {
|
||||
s.expandWildcards = expandWildcards
|
||||
return s
|
||||
}
|
||||
|
||||
// Lenient specifies whether format-based query failures (such as providing
|
||||
// text to a numeric field) should be ignored.
|
||||
func (s *XPackAsyncSearchSubmit) Lenient(lenient bool) *XPackAsyncSearchSubmit {
|
||||
s.lenient = &lenient
|
||||
return s
|
||||
}
|
||||
|
||||
// MaxResponseSize sets an upper limit on the response body size that we accept,
|
||||
// to guard against OOM situations.
|
||||
func (s *XPackAsyncSearchSubmit) MaxResponseSize(maxResponseSize int64) *XPackAsyncSearchSubmit {
|
||||
s.maxResponseSize = maxResponseSize
|
||||
return s
|
||||
}
|
||||
|
||||
// AllowPartialSearchResults indicates if an error should be returned if
|
||||
// there is a partial search failure or timeout.
|
||||
func (s *XPackAsyncSearchSubmit) AllowPartialSearchResults(enabled bool) *XPackAsyncSearchSubmit {
|
||||
s.allowPartialSearchResults = &enabled
|
||||
return s
|
||||
}
|
||||
|
||||
// TypedKeys specifies whether aggregation and suggester names should be
|
||||
// prefixed by their respective types in the response.
|
||||
func (s *XPackAsyncSearchSubmit) TypedKeys(enabled bool) *XPackAsyncSearchSubmit {
|
||||
s.typedKeys = &enabled
|
||||
return s
|
||||
}
|
||||
|
||||
// SeqNoPrimaryTerm specifies whether to return sequence number and
|
||||
// primary term of the last modification of each hit.
|
||||
func (s *XPackAsyncSearchSubmit) SeqNoPrimaryTerm(enabled bool) *XPackAsyncSearchSubmit {
|
||||
s.seqNoPrimaryTerm = &enabled
|
||||
return s
|
||||
}
|
||||
|
||||
// BatchedReduceSize specifies the number of shard results that should be reduced
|
||||
// at once on the coordinating node. This value should be used as a protection
|
||||
// mechanism to reduce the memory overhead per search request if the potential
|
||||
// number of shards in the request can be large.
|
||||
func (s *XPackAsyncSearchSubmit) BatchedReduceSize(size int) *XPackAsyncSearchSubmit {
|
||||
s.batchedReduceSize = &size
|
||||
return s
|
||||
}
|
||||
|
||||
// MaxConcurrentShardRequests specifies the number of concurrent shard requests
|
||||
// this search executes concurrently. This value should be used to limit the
|
||||
// impact of the search on the cluster in order to limit the number of
|
||||
// concurrent shard requests.
|
||||
func (s *XPackAsyncSearchSubmit) MaxConcurrentShardRequests(max int) *XPackAsyncSearchSubmit {
|
||||
s.maxConcurrentShardRequests = &max
|
||||
return s
|
||||
}
|
||||
|
||||
// PreFilterShardSize specifies a threshold that enforces a pre-filter roundtrip
|
||||
// to prefilter search shards based on query rewriting if the number of shards
|
||||
// the search request expands to exceeds the threshold. This filter roundtrip
|
||||
// can limit the number of shards significantly if for instance a shard can
|
||||
// not match any documents based on it's rewrite method i.e. if date filters are
|
||||
// mandatory to match but the shard bounds and the query are disjoint.
|
||||
func (s *XPackAsyncSearchSubmit) PreFilterShardSize(threshold int) *XPackAsyncSearchSubmit {
|
||||
s.preFilterShardSize = &threshold
|
||||
return s
|
||||
}
|
||||
|
||||
// RestTotalHitsAsInt indicates whether hits.total should be rendered as an
|
||||
// integer or an object in the rest search response.
|
||||
func (s *XPackAsyncSearchSubmit) RestTotalHitsAsInt(enabled bool) *XPackAsyncSearchSubmit {
|
||||
s.restTotalHitsAsInt = &enabled
|
||||
return s
|
||||
}
|
||||
|
||||
// CCSMinimizeRoundtrips indicates whether network round-trips should be minimized
|
||||
// as part of cross-cluster search requests execution.
|
||||
func (s *XPackAsyncSearchSubmit) CCSMinimizeRoundtrips(enabled bool) *XPackAsyncSearchSubmit {
|
||||
s.ccsMinimizeRoundtrips = &enabled
|
||||
return s
|
||||
}
|
||||
|
||||
// WaitForCompletionTimeout is suitable for DoAsync only. It specifies the
|
||||
// timeout for the Search to wait for completion before returning an ID to
|
||||
// return the results asynchronously. In other words: If the search takes
|
||||
// longer than this value (default is 1 second), then you need to call
|
||||
// GetAsync to retrieve its final results.
|
||||
func (s *XPackAsyncSearchSubmit) WaitForCompletionTimeout(timeout string) *XPackAsyncSearchSubmit {
|
||||
s.waitForCompletionTimeout = timeout
|
||||
return s
|
||||
}
|
||||
|
||||
// KeepOnCompletion is suitable for DoAsync only. It indicates whether the
|
||||
// asynchronous search ID and its results should be kept even after the
|
||||
// search (and its results) are completed and retrieved.
|
||||
func (s *XPackAsyncSearchSubmit) KeepOnCompletion(keepOnCompletion bool) *XPackAsyncSearchSubmit {
|
||||
s.keepOnCompletion = &keepOnCompletion
|
||||
return s
|
||||
}
|
||||
|
||||
// KeepAlive can only be used with DoAsync. If set, KeepAlive specifies the
|
||||
// duration after which search ID and its results are removed from the
|
||||
// Elasticsearch cluster and hence can no longer be retrieved with GetAsync.
|
||||
func (s *XPackAsyncSearchSubmit) KeepAlive(keepAlive string) *XPackAsyncSearchSubmit {
|
||||
s.keepAlive = keepAlive
|
||||
return s
|
||||
}
|
||||
|
||||
// buildURL builds the URL for the operation.
|
||||
func (s *XPackAsyncSearchSubmit) buildURL() (string, url.Values, error) {
|
||||
var err error
|
||||
var path string
|
||||
|
||||
if len(s.index) > 0 && len(s.typ) > 0 {
|
||||
path, err = uritemplates.Expand("/{index}/{type}/_async_search", map[string]string{
|
||||
"index": strings.Join(s.index, ","),
|
||||
"type": strings.Join(s.typ, ","),
|
||||
})
|
||||
} else if len(s.index) > 0 {
|
||||
path, err = uritemplates.Expand("/{index}/_async_search", map[string]string{
|
||||
"index": strings.Join(s.index, ","),
|
||||
})
|
||||
} else if len(s.typ) > 0 {
|
||||
path, err = uritemplates.Expand("/_all/{type}/_async_search", map[string]string{
|
||||
"type": strings.Join(s.typ, ","),
|
||||
})
|
||||
} else {
|
||||
path = "/_async_search"
|
||||
}
|
||||
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.searchType != "" {
|
||||
params.Set("search_type", s.searchType)
|
||||
}
|
||||
if s.routing != "" {
|
||||
params.Set("routing", s.routing)
|
||||
}
|
||||
if s.preference != "" {
|
||||
params.Set("preference", s.preference)
|
||||
}
|
||||
if v := s.requestCache; v != nil {
|
||||
params.Set("request_cache", fmt.Sprint(*v))
|
||||
}
|
||||
if v := s.allowNoIndices; v != nil {
|
||||
params.Set("allow_no_indices", fmt.Sprint(*v))
|
||||
}
|
||||
if s.expandWildcards != "" {
|
||||
params.Set("expand_wildcards", s.expandWildcards)
|
||||
}
|
||||
if v := s.lenient; v != nil {
|
||||
params.Set("lenient", fmt.Sprint(*v))
|
||||
}
|
||||
if v := s.ignoreUnavailable; v != nil {
|
||||
params.Set("ignore_unavailable", fmt.Sprint(*v))
|
||||
}
|
||||
if v := s.ignoreThrottled; v != nil {
|
||||
params.Set("ignore_throttled", fmt.Sprint(*v))
|
||||
}
|
||||
if s.seqNoPrimaryTerm != nil {
|
||||
params.Set("seq_no_primary_term", fmt.Sprint(*s.seqNoPrimaryTerm))
|
||||
}
|
||||
if v := s.allowPartialSearchResults; v != nil {
|
||||
params.Set("allow_partial_search_results", fmt.Sprint(*v))
|
||||
}
|
||||
if v := s.typedKeys; v != nil {
|
||||
params.Set("typed_keys", fmt.Sprint(*v))
|
||||
}
|
||||
if v := s.batchedReduceSize; v != nil {
|
||||
params.Set("batched_reduce_size", fmt.Sprint(*v))
|
||||
}
|
||||
if v := s.maxConcurrentShardRequests; v != nil {
|
||||
params.Set("max_concurrent_shard_requests", fmt.Sprint(*v))
|
||||
}
|
||||
if v := s.preFilterShardSize; v != nil {
|
||||
params.Set("pre_filter_shard_size", fmt.Sprint(*v))
|
||||
}
|
||||
if v := s.restTotalHitsAsInt; v != nil {
|
||||
params.Set("rest_total_hits_as_int", fmt.Sprint(*v))
|
||||
}
|
||||
if v := s.ccsMinimizeRoundtrips; v != nil {
|
||||
params.Set("ccs_minimize_roundtrips", fmt.Sprint(*v))
|
||||
}
|
||||
if s.waitForCompletionTimeout != "" {
|
||||
params.Set("wait_for_completion_timeout", s.waitForCompletionTimeout)
|
||||
}
|
||||
if v := s.keepOnCompletion; v != nil {
|
||||
params.Set("keep_on_completion", fmt.Sprint(*v))
|
||||
}
|
||||
if s.keepAlive != "" {
|
||||
params.Set("keep_alive", s.keepAlive)
|
||||
}
|
||||
return path, params, nil
|
||||
}
|
||||
|
||||
// Validate checks if the operation is valid.
|
||||
func (s *XPackAsyncSearchSubmit) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Do executes the search and returns a XPackAsyncSearchResult.
|
||||
func (s *XPackAsyncSearchSubmit) Do(ctx context.Context) (*XPackAsyncSearchResult, 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
|
||||
}
|
||||
|
||||
// Perform request
|
||||
var body interface{}
|
||||
if s.source != nil {
|
||||
body = s.source
|
||||
} else {
|
||||
src, err := s.searchSource.Source()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
body = src
|
||||
}
|
||||
res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
|
||||
Method: "POST",
|
||||
Path: path,
|
||||
Params: params,
|
||||
Body: body,
|
||||
Headers: s.headers,
|
||||
MaxResponseSize: s.maxResponseSize,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Return search results
|
||||
ret := new(XPackAsyncSearchResult)
|
||||
if err := s.client.decoder.Decode(res.Body, ret); err != nil {
|
||||
ret.Header = res.Header
|
||||
return nil, err
|
||||
}
|
||||
ret.Header = res.Header
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// XPackAsyncSearchResult is the outcome of starting an asynchronous search
|
||||
// or retrieving a search result with XPackAsyncSearchGet.
|
||||
type XPackAsyncSearchResult struct {
|
||||
Header http.Header `json:"-"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsRunning bool `json:"is_running"`
|
||||
IsPartial bool `json:"is_partial"`
|
||||
StartTimeMillis int64 `json:"start_time_in_millis,omitempty"`
|
||||
ExpirationTimeMillis int64 `json:"expiration_time_in_millis,omitempty"`
|
||||
Response *SearchResult `json:"response,omitempty"`
|
||||
Error *ErrorDetails `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// Each is a utility function to iterate over all hits. It saves you from
|
||||
// checking for nil values. Notice that Each will ignore errors in
|
||||
// serializing JSON and hits with empty/nil _source will get an empty
|
||||
// value
|
||||
func (r *XPackAsyncSearchResult) Each(typ reflect.Type) []interface{} {
|
||||
if r == nil || r.Response == nil || r.Response.Hits == nil || r.Response.Hits.Hits == nil || len(r.Response.Hits.Hits) == 0 {
|
||||
return nil
|
||||
}
|
||||
var slice []interface{}
|
||||
for _, hit := range r.Response.Hits.Hits {
|
||||
v := reflect.New(typ).Elem()
|
||||
if hit.Source == nil {
|
||||
slice = append(slice, v.Interface())
|
||||
continue
|
||||
}
|
||||
if err := json.Unmarshal(hit.Source, v.Addr().Interface()); err == nil {
|
||||
slice = append(slice, v.Interface())
|
||||
}
|
||||
}
|
||||
return slice
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue