repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequence | docstring
stringlengths 6
2.61k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 85
252
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
olivere/elastic | validate.go | Explain | func (s *ValidateService) Explain(explain *bool) *ValidateService {
s.explain = explain
return s
} | go | func (s *ValidateService) Explain(explain *bool) *ValidateService {
s.explain = explain
return s
} | [
"func",
"(",
"s",
"*",
"ValidateService",
")",
"Explain",
"(",
"explain",
"*",
"bool",
")",
"*",
"ValidateService",
"{",
"s",
".",
"explain",
"=",
"explain",
"\n",
"return",
"s",
"\n",
"}"
] | // An explain parameter can be specified to get more detailed information about why a query failed. | [
"An",
"explain",
"parameter",
"can",
"be",
"specified",
"to",
"get",
"more",
"detailed",
"information",
"about",
"why",
"a",
"query",
"failed",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/validate.go#L76-L79 | train |
olivere/elastic | validate.go | Rewrite | func (s *ValidateService) Rewrite(rewrite *bool) *ValidateService {
s.rewrite = rewrite
return s
} | go | func (s *ValidateService) Rewrite(rewrite *bool) *ValidateService {
s.rewrite = rewrite
return s
} | [
"func",
"(",
"s",
"*",
"ValidateService",
")",
"Rewrite",
"(",
"rewrite",
"*",
"bool",
")",
"*",
"ValidateService",
"{",
"s",
".",
"rewrite",
"=",
"rewrite",
"\n",
"return",
"s",
"\n",
"}"
] | // Provide a more detailed explanation showing the actual Lucene query that will be executed. | [
"Provide",
"a",
"more",
"detailed",
"explanation",
"showing",
"the",
"actual",
"Lucene",
"query",
"that",
"will",
"be",
"executed",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/validate.go#L82-L85 | train |
olivere/elastic | validate.go | AllShards | func (s *ValidateService) AllShards(allShards *bool) *ValidateService {
s.allShards = allShards
return s
} | go | func (s *ValidateService) AllShards(allShards *bool) *ValidateService {
s.allShards = allShards
return s
} | [
"func",
"(",
"s",
"*",
"ValidateService",
")",
"AllShards",
"(",
"allShards",
"*",
"bool",
")",
"*",
"ValidateService",
"{",
"s",
".",
"allShards",
"=",
"allShards",
"\n",
"return",
"s",
"\n",
"}"
] | // Execute validation on all shards instead of one random shard per index. | [
"Execute",
"validation",
"on",
"all",
"shards",
"instead",
"of",
"one",
"random",
"shard",
"per",
"index",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/validate.go#L88-L91 | train |
olivere/elastic | bulk_index_request.go | Index | func (r *BulkIndexRequest) Index(index string) *BulkIndexRequest {
r.index = index
r.source = nil
return r
} | go | func (r *BulkIndexRequest) Index(index string) *BulkIndexRequest {
r.index = index
r.source = nil
return r
} | [
"func",
"(",
"r",
"*",
"BulkIndexRequest",
")",
"Index",
"(",
"index",
"string",
")",
"*",
"BulkIndexRequest",
"{",
"r",
".",
"index",
"=",
"index",
"\n",
"r",
".",
"source",
"=",
"nil",
"\n",
"return",
"r",
"\n",
"}"
] | // Index specifies the Elasticsearch index to use for this index request.
// If unspecified, the index set on the BulkService will be used. | [
"Index",
"specifies",
"the",
"Elasticsearch",
"index",
"to",
"use",
"for",
"this",
"index",
"request",
".",
"If",
"unspecified",
"the",
"index",
"set",
"on",
"the",
"BulkService",
"will",
"be",
"used",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk_index_request.go#L75-L79 | train |
olivere/elastic | bulk_index_request.go | Type | func (r *BulkIndexRequest) Type(typ string) *BulkIndexRequest {
r.typ = typ
r.source = nil
return r
} | go | func (r *BulkIndexRequest) Type(typ string) *BulkIndexRequest {
r.typ = typ
r.source = nil
return r
} | [
"func",
"(",
"r",
"*",
"BulkIndexRequest",
")",
"Type",
"(",
"typ",
"string",
")",
"*",
"BulkIndexRequest",
"{",
"r",
".",
"typ",
"=",
"typ",
"\n",
"r",
".",
"source",
"=",
"nil",
"\n",
"return",
"r",
"\n",
"}"
] | // Type specifies the Elasticsearch type to use for this index request.
// If unspecified, the type set on the BulkService will be used. | [
"Type",
"specifies",
"the",
"Elasticsearch",
"type",
"to",
"use",
"for",
"this",
"index",
"request",
".",
"If",
"unspecified",
"the",
"type",
"set",
"on",
"the",
"BulkService",
"will",
"be",
"used",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk_index_request.go#L83-L87 | train |
olivere/elastic | bulk_index_request.go | Id | func (r *BulkIndexRequest) Id(id string) *BulkIndexRequest {
r.id = id
r.source = nil
return r
} | go | func (r *BulkIndexRequest) Id(id string) *BulkIndexRequest {
r.id = id
r.source = nil
return r
} | [
"func",
"(",
"r",
"*",
"BulkIndexRequest",
")",
"Id",
"(",
"id",
"string",
")",
"*",
"BulkIndexRequest",
"{",
"r",
".",
"id",
"=",
"id",
"\n",
"r",
".",
"source",
"=",
"nil",
"\n",
"return",
"r",
"\n",
"}"
] | // Id specifies the identifier of the document to index. | [
"Id",
"specifies",
"the",
"identifier",
"of",
"the",
"document",
"to",
"index",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk_index_request.go#L90-L94 | train |
olivere/elastic | bulk_index_request.go | Doc | func (r *BulkIndexRequest) Doc(doc interface{}) *BulkIndexRequest {
r.doc = doc
r.source = nil
return r
} | go | func (r *BulkIndexRequest) Doc(doc interface{}) *BulkIndexRequest {
r.doc = doc
r.source = nil
return r
} | [
"func",
"(",
"r",
"*",
"BulkIndexRequest",
")",
"Doc",
"(",
"doc",
"interface",
"{",
"}",
")",
"*",
"BulkIndexRequest",
"{",
"r",
".",
"doc",
"=",
"doc",
"\n",
"r",
".",
"source",
"=",
"nil",
"\n",
"return",
"r",
"\n",
"}"
] | // Doc specifies the document to index. | [
"Doc",
"specifies",
"the",
"document",
"to",
"index",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk_index_request.go#L141-L145 | train |
olivere/elastic | bulk_index_request.go | Pipeline | func (r *BulkIndexRequest) Pipeline(pipeline string) *BulkIndexRequest {
r.pipeline = pipeline
r.source = nil
return r
} | go | func (r *BulkIndexRequest) Pipeline(pipeline string) *BulkIndexRequest {
r.pipeline = pipeline
r.source = nil
return r
} | [
"func",
"(",
"r",
"*",
"BulkIndexRequest",
")",
"Pipeline",
"(",
"pipeline",
"string",
")",
"*",
"BulkIndexRequest",
"{",
"r",
".",
"pipeline",
"=",
"pipeline",
"\n",
"r",
".",
"source",
"=",
"nil",
"\n",
"return",
"r",
"\n",
"}"
] | // Pipeline to use while processing the request. | [
"Pipeline",
"to",
"use",
"while",
"processing",
"the",
"request",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk_index_request.go#L155-L159 | train |
olivere/elastic | xpack_security_get_role_mapping.go | Name | func (s *XPackSecurityGetRoleMappingService) Name(name string) *XPackSecurityGetRoleMappingService {
s.name = name
return s
} | go | func (s *XPackSecurityGetRoleMappingService) Name(name string) *XPackSecurityGetRoleMappingService {
s.name = name
return s
} | [
"func",
"(",
"s",
"*",
"XPackSecurityGetRoleMappingService",
")",
"Name",
"(",
"name",
"string",
")",
"*",
"XPackSecurityGetRoleMappingService",
"{",
"s",
".",
"name",
"=",
"name",
"\n",
"return",
"s",
"\n",
"}"
] | // Name is name of the role mapping to retrieve. | [
"Name",
"is",
"name",
"of",
"the",
"role",
"mapping",
"to",
"retrieve",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/xpack_security_get_role_mapping.go#L32-L35 | train |
olivere/elastic | search_queries_constant_score.go | Source | func (q *ConstantScoreQuery) Source() (interface{}, error) {
// "constant_score" : {
// "filter" : {
// ....
// },
// "boost" : 1.5
// }
query := make(map[string]interface{})
params := make(map[string]interface{})
query["constant_score"] = params
// filter
src, err := q.filter.Source()
if err != nil {
return nil, err
}
params["filter"] = src
// boost
if q.boost != nil {
params["boost"] = *q.boost
}
return query, nil
} | go | func (q *ConstantScoreQuery) Source() (interface{}, error) {
// "constant_score" : {
// "filter" : {
// ....
// },
// "boost" : 1.5
// }
query := make(map[string]interface{})
params := make(map[string]interface{})
query["constant_score"] = params
// filter
src, err := q.filter.Source()
if err != nil {
return nil, err
}
params["filter"] = src
// boost
if q.boost != nil {
params["boost"] = *q.boost
}
return query, nil
} | [
"func",
"(",
"q",
"*",
"ConstantScoreQuery",
")",
"Source",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// \"constant_score\" : {",
"// \"filter\" : {",
"// ....",
"// },",
"// \"boost\" : 1.5",
"// }",
"query",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n\n",
"params",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"query",
"[",
"\"",
"\"",
"]",
"=",
"params",
"\n\n",
"// filter",
"src",
",",
"err",
":=",
"q",
".",
"filter",
".",
"Source",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"params",
"[",
"\"",
"\"",
"]",
"=",
"src",
"\n\n",
"// boost",
"if",
"q",
".",
"boost",
"!=",
"nil",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"*",
"q",
".",
"boost",
"\n",
"}",
"\n\n",
"return",
"query",
",",
"nil",
"\n",
"}"
] | // Source returns the query source. | [
"Source",
"returns",
"the",
"query",
"source",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_constant_score.go#L33-L59 | train |
olivere/elastic | search_aggs_bucket_filters.go | NewFiltersAggregation | func NewFiltersAggregation() *FiltersAggregation {
return &FiltersAggregation{
unnamedFilters: make([]Query, 0),
namedFilters: make(map[string]Query),
subAggregations: make(map[string]Aggregation),
}
} | go | func NewFiltersAggregation() *FiltersAggregation {
return &FiltersAggregation{
unnamedFilters: make([]Query, 0),
namedFilters: make(map[string]Query),
subAggregations: make(map[string]Aggregation),
}
} | [
"func",
"NewFiltersAggregation",
"(",
")",
"*",
"FiltersAggregation",
"{",
"return",
"&",
"FiltersAggregation",
"{",
"unnamedFilters",
":",
"make",
"(",
"[",
"]",
"Query",
",",
"0",
")",
",",
"namedFilters",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"Query",
")",
",",
"subAggregations",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"Aggregation",
")",
",",
"}",
"\n",
"}"
] | // NewFiltersAggregation initializes a new FiltersAggregation. | [
"NewFiltersAggregation",
"initializes",
"a",
"new",
"FiltersAggregation",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_aggs_bucket_filters.go#L27-L33 | train |
olivere/elastic | search_aggs_bucket_filters.go | Filter | func (a *FiltersAggregation) Filter(filter Query) *FiltersAggregation {
a.unnamedFilters = append(a.unnamedFilters, filter)
return a
} | go | func (a *FiltersAggregation) Filter(filter Query) *FiltersAggregation {
a.unnamedFilters = append(a.unnamedFilters, filter)
return a
} | [
"func",
"(",
"a",
"*",
"FiltersAggregation",
")",
"Filter",
"(",
"filter",
"Query",
")",
"*",
"FiltersAggregation",
"{",
"a",
".",
"unnamedFilters",
"=",
"append",
"(",
"a",
".",
"unnamedFilters",
",",
"filter",
")",
"\n",
"return",
"a",
"\n",
"}"
] | // Filter adds an unnamed filter. Notice that you can
// either use named or unnamed filters, but not both. | [
"Filter",
"adds",
"an",
"unnamed",
"filter",
".",
"Notice",
"that",
"you",
"can",
"either",
"use",
"named",
"or",
"unnamed",
"filters",
"but",
"not",
"both",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_aggs_bucket_filters.go#L37-L40 | train |
olivere/elastic | search_aggs_bucket_filters.go | Filters | func (a *FiltersAggregation) Filters(filters ...Query) *FiltersAggregation {
if len(filters) > 0 {
a.unnamedFilters = append(a.unnamedFilters, filters...)
}
return a
} | go | func (a *FiltersAggregation) Filters(filters ...Query) *FiltersAggregation {
if len(filters) > 0 {
a.unnamedFilters = append(a.unnamedFilters, filters...)
}
return a
} | [
"func",
"(",
"a",
"*",
"FiltersAggregation",
")",
"Filters",
"(",
"filters",
"...",
"Query",
")",
"*",
"FiltersAggregation",
"{",
"if",
"len",
"(",
"filters",
")",
">",
"0",
"{",
"a",
".",
"unnamedFilters",
"=",
"append",
"(",
"a",
".",
"unnamedFilters",
",",
"filters",
"...",
")",
"\n",
"}",
"\n",
"return",
"a",
"\n",
"}"
] | // Filters adds one or more unnamed filters. Notice that you can
// either use named or unnamed filters, but not both. | [
"Filters",
"adds",
"one",
"or",
"more",
"unnamed",
"filters",
".",
"Notice",
"that",
"you",
"can",
"either",
"use",
"named",
"or",
"unnamed",
"filters",
"but",
"not",
"both",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_aggs_bucket_filters.go#L44-L49 | train |
olivere/elastic | search_aggs_bucket_filters.go | FilterWithName | func (a *FiltersAggregation) FilterWithName(name string, filter Query) *FiltersAggregation {
a.namedFilters[name] = filter
return a
} | go | func (a *FiltersAggregation) FilterWithName(name string, filter Query) *FiltersAggregation {
a.namedFilters[name] = filter
return a
} | [
"func",
"(",
"a",
"*",
"FiltersAggregation",
")",
"FilterWithName",
"(",
"name",
"string",
",",
"filter",
"Query",
")",
"*",
"FiltersAggregation",
"{",
"a",
".",
"namedFilters",
"[",
"name",
"]",
"=",
"filter",
"\n",
"return",
"a",
"\n",
"}"
] | // FilterWithName adds a filter with a specific name. Notice that you can
// either use named or unnamed filters, but not both. | [
"FilterWithName",
"adds",
"a",
"filter",
"with",
"a",
"specific",
"name",
".",
"Notice",
"that",
"you",
"can",
"either",
"use",
"named",
"or",
"unnamed",
"filters",
"but",
"not",
"both",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_aggs_bucket_filters.go#L53-L56 | train |
olivere/elastic | scroll.go | NewScrollService | func NewScrollService(client *Client) *ScrollService {
builder := &ScrollService{
client: client,
ss: NewSearchSource(),
keepAlive: DefaultScrollKeepAlive,
}
return builder
} | go | func NewScrollService(client *Client) *ScrollService {
builder := &ScrollService{
client: client,
ss: NewSearchSource(),
keepAlive: DefaultScrollKeepAlive,
}
return builder
} | [
"func",
"NewScrollService",
"(",
"client",
"*",
"Client",
")",
"*",
"ScrollService",
"{",
"builder",
":=",
"&",
"ScrollService",
"{",
"client",
":",
"client",
",",
"ss",
":",
"NewSearchSource",
"(",
")",
",",
"keepAlive",
":",
"DefaultScrollKeepAlive",
",",
"}",
"\n",
"return",
"builder",
"\n",
"}"
] | // NewScrollService initializes and returns a new ScrollService. | [
"NewScrollService",
"initializes",
"and",
"returns",
"a",
"new",
"ScrollService",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L49-L56 | train |
olivere/elastic | scroll.go | Retrier | func (s *ScrollService) Retrier(retrier Retrier) *ScrollService {
s.retrier = retrier
return s
} | go | func (s *ScrollService) Retrier(retrier Retrier) *ScrollService {
s.retrier = retrier
return s
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"Retrier",
"(",
"retrier",
"Retrier",
")",
"*",
"ScrollService",
"{",
"s",
".",
"retrier",
"=",
"retrier",
"\n",
"return",
"s",
"\n",
"}"
] | // Retrier allows to set specific retry logic for this ScrollService.
// If not specified, it will use the client's default retrier. | [
"Retrier",
"allows",
"to",
"set",
"specific",
"retry",
"logic",
"for",
"this",
"ScrollService",
".",
"If",
"not",
"specified",
"it",
"will",
"use",
"the",
"client",
"s",
"default",
"retrier",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L69-L72 | train |
olivere/elastic | scroll.go | Index | func (s *ScrollService) Index(indices ...string) *ScrollService {
if s.indices == nil {
s.indices = make([]string, 0)
}
s.indices = append(s.indices, indices...)
return s
} | go | func (s *ScrollService) Index(indices ...string) *ScrollService {
if s.indices == nil {
s.indices = make([]string, 0)
}
s.indices = append(s.indices, indices...)
return s
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"Index",
"(",
"indices",
"...",
"string",
")",
"*",
"ScrollService",
"{",
"if",
"s",
".",
"indices",
"==",
"nil",
"{",
"s",
".",
"indices",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"}",
"\n",
"s",
".",
"indices",
"=",
"append",
"(",
"s",
".",
"indices",
",",
"indices",
"...",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // Index sets the name of one or more indices to iterate over. | [
"Index",
"sets",
"the",
"name",
"of",
"one",
"or",
"more",
"indices",
"to",
"iterate",
"over",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L75-L81 | train |
olivere/elastic | scroll.go | KeepAlive | func (s *ScrollService) KeepAlive(keepAlive string) *ScrollService {
s.keepAlive = keepAlive
return s
} | go | func (s *ScrollService) KeepAlive(keepAlive string) *ScrollService {
s.keepAlive = keepAlive
return s
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"KeepAlive",
"(",
"keepAlive",
"string",
")",
"*",
"ScrollService",
"{",
"s",
".",
"keepAlive",
"=",
"keepAlive",
"\n",
"return",
"s",
"\n",
"}"
] | // KeepAlive sets the maximum time after which the cursor will expire.
// It is "5m" by default. | [
"KeepAlive",
"sets",
"the",
"maximum",
"time",
"after",
"which",
"the",
"cursor",
"will",
"expire",
".",
"It",
"is",
"5m",
"by",
"default",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L101-L104 | train |
olivere/elastic | scroll.go | Size | func (s *ScrollService) Size(size int) *ScrollService {
s.size = &size
return s
} | go | func (s *ScrollService) Size(size int) *ScrollService {
s.size = &size
return s
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"Size",
"(",
"size",
"int",
")",
"*",
"ScrollService",
"{",
"s",
".",
"size",
"=",
"&",
"size",
"\n",
"return",
"s",
"\n",
"}"
] | // Size specifies the number of documents Elasticsearch should return
// from each shard, per page. | [
"Size",
"specifies",
"the",
"number",
"of",
"documents",
"Elasticsearch",
"should",
"return",
"from",
"each",
"shard",
"per",
"page",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L108-L111 | train |
olivere/elastic | scroll.go | Sort | func (s *ScrollService) Sort(field string, ascending bool) *ScrollService {
s.ss = s.ss.Sort(field, ascending)
return s
} | go | func (s *ScrollService) Sort(field string, ascending bool) *ScrollService {
s.ss = s.ss.Sort(field, ascending)
return s
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"Sort",
"(",
"field",
"string",
",",
"ascending",
"bool",
")",
"*",
"ScrollService",
"{",
"s",
".",
"ss",
"=",
"s",
".",
"ss",
".",
"Sort",
"(",
"field",
",",
"ascending",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // Sort adds a sort order. This can have negative effects on the performance
// of the scroll operation as Elasticsearch needs to sort first. | [
"Sort",
"adds",
"a",
"sort",
"order",
".",
"This",
"can",
"have",
"negative",
"effects",
"on",
"the",
"performance",
"of",
"the",
"scroll",
"operation",
"as",
"Elasticsearch",
"needs",
"to",
"sort",
"first",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L179-L182 | train |
olivere/elastic | scroll.go | SortWithInfo | func (s *ScrollService) SortWithInfo(info SortInfo) *ScrollService {
s.ss = s.ss.SortWithInfo(info)
return s
} | go | func (s *ScrollService) SortWithInfo(info SortInfo) *ScrollService {
s.ss = s.ss.SortWithInfo(info)
return s
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"SortWithInfo",
"(",
"info",
"SortInfo",
")",
"*",
"ScrollService",
"{",
"s",
".",
"ss",
"=",
"s",
".",
"ss",
".",
"SortWithInfo",
"(",
"info",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // SortWithInfo specifies a sort order. Notice that sorting can have a
// negative impact on scroll performance. | [
"SortWithInfo",
"specifies",
"a",
"sort",
"order",
".",
"Notice",
"that",
"sorting",
"can",
"have",
"a",
"negative",
"impact",
"on",
"scroll",
"performance",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L186-L189 | train |
olivere/elastic | scroll.go | SortBy | func (s *ScrollService) SortBy(sorter ...Sorter) *ScrollService {
s.ss = s.ss.SortBy(sorter...)
return s
} | go | func (s *ScrollService) SortBy(sorter ...Sorter) *ScrollService {
s.ss = s.ss.SortBy(sorter...)
return s
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"SortBy",
"(",
"sorter",
"...",
"Sorter",
")",
"*",
"ScrollService",
"{",
"s",
".",
"ss",
"=",
"s",
".",
"ss",
".",
"SortBy",
"(",
"sorter",
"...",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // SortBy specifies a sort order. Notice that sorting can have a
// negative impact on scroll performance. | [
"SortBy",
"specifies",
"a",
"sort",
"order",
".",
"Notice",
"that",
"sorting",
"can",
"have",
"a",
"negative",
"impact",
"on",
"scroll",
"performance",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L193-L196 | train |
olivere/elastic | scroll.go | Pretty | func (s *ScrollService) Pretty(pretty bool) *ScrollService {
s.pretty = pretty
return s
} | go | func (s *ScrollService) Pretty(pretty bool) *ScrollService {
s.pretty = pretty
return s
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"Pretty",
"(",
"pretty",
"bool",
")",
"*",
"ScrollService",
"{",
"s",
".",
"pretty",
"=",
"pretty",
"\n",
"return",
"s",
"\n",
"}"
] | // Pretty asks Elasticsearch to pretty-print the returned JSON. | [
"Pretty",
"asks",
"Elasticsearch",
"to",
"pretty",
"-",
"print",
"the",
"returned",
"JSON",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L199-L202 | train |
olivere/elastic | scroll.go | ScrollId | func (s *ScrollService) ScrollId(scrollId string) *ScrollService {
s.mu.Lock()
s.scrollId = scrollId
s.mu.Unlock()
return s
} | go | func (s *ScrollService) ScrollId(scrollId string) *ScrollService {
s.mu.Lock()
s.scrollId = scrollId
s.mu.Unlock()
return s
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"ScrollId",
"(",
"scrollId",
"string",
")",
"*",
"ScrollService",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"scrollId",
"=",
"scrollId",
"\n",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // ScrollId specifies the identifier of a scroll in action. | [
"ScrollId",
"specifies",
"the",
"identifier",
"of",
"a",
"scroll",
"in",
"action",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L259-L264 | train |
olivere/elastic | scroll.go | Do | func (s *ScrollService) Do(ctx context.Context) (*SearchResult, error) {
s.mu.RLock()
nextScrollId := s.scrollId
s.mu.RUnlock()
if len(nextScrollId) == 0 {
return s.first(ctx)
}
return s.next(ctx)
} | go | func (s *ScrollService) Do(ctx context.Context) (*SearchResult, error) {
s.mu.RLock()
nextScrollId := s.scrollId
s.mu.RUnlock()
if len(nextScrollId) == 0 {
return s.first(ctx)
}
return s.next(ctx)
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"Do",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"SearchResult",
",",
"error",
")",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"nextScrollId",
":=",
"s",
".",
"scrollId",
"\n",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"len",
"(",
"nextScrollId",
")",
"==",
"0",
"{",
"return",
"s",
".",
"first",
"(",
"ctx",
")",
"\n",
"}",
"\n",
"return",
"s",
".",
"next",
"(",
"ctx",
")",
"\n",
"}"
] | // Do returns the next search result. It will return io.EOF as error if there
// are no more search results. | [
"Do",
"returns",
"the",
"next",
"search",
"result",
".",
"It",
"will",
"return",
"io",
".",
"EOF",
"as",
"error",
"if",
"there",
"are",
"no",
"more",
"search",
"results",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L268-L276 | train |
olivere/elastic | scroll.go | Clear | func (s *ScrollService) Clear(ctx context.Context) error {
s.mu.RLock()
scrollId := s.scrollId
s.mu.RUnlock()
if len(scrollId) == 0 {
return nil
}
path := "/_search/scroll"
params := url.Values{}
body := struct {
ScrollId []string `json:"scroll_id,omitempty"`
}{
ScrollId: []string{scrollId},
}
_, err := s.client.PerformRequest(ctx, PerformRequestOptions{
Method: "DELETE",
Path: path,
Params: params,
Body: body,
Retrier: s.retrier,
})
if err != nil {
return err
}
return nil
} | go | func (s *ScrollService) Clear(ctx context.Context) error {
s.mu.RLock()
scrollId := s.scrollId
s.mu.RUnlock()
if len(scrollId) == 0 {
return nil
}
path := "/_search/scroll"
params := url.Values{}
body := struct {
ScrollId []string `json:"scroll_id,omitempty"`
}{
ScrollId: []string{scrollId},
}
_, err := s.client.PerformRequest(ctx, PerformRequestOptions{
Method: "DELETE",
Path: path,
Params: params,
Body: body,
Retrier: s.retrier,
})
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"Clear",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"scrollId",
":=",
"s",
".",
"scrollId",
"\n",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"len",
"(",
"scrollId",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"path",
":=",
"\"",
"\"",
"\n",
"params",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"body",
":=",
"struct",
"{",
"ScrollId",
"[",
"]",
"string",
"`json:\"scroll_id,omitempty\"`",
"\n",
"}",
"{",
"ScrollId",
":",
"[",
"]",
"string",
"{",
"scrollId",
"}",
",",
"}",
"\n\n",
"_",
",",
"err",
":=",
"s",
".",
"client",
".",
"PerformRequest",
"(",
"ctx",
",",
"PerformRequestOptions",
"{",
"Method",
":",
"\"",
"\"",
",",
"Path",
":",
"path",
",",
"Params",
":",
"params",
",",
"Body",
":",
"body",
",",
"Retrier",
":",
"s",
".",
"retrier",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Clear cancels the current scroll operation. If you don't do this manually,
// the scroll will be expired automatically by Elasticsearch. You can control
// how long a scroll cursor is kept alive with the KeepAlive func. | [
"Clear",
"cancels",
"the",
"current",
"scroll",
"operation",
".",
"If",
"you",
"don",
"t",
"do",
"this",
"manually",
"the",
"scroll",
"will",
"be",
"expired",
"automatically",
"by",
"Elasticsearch",
".",
"You",
"can",
"control",
"how",
"long",
"a",
"scroll",
"cursor",
"is",
"kept",
"alive",
"with",
"the",
"KeepAlive",
"func",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L281-L309 | train |
olivere/elastic | scroll.go | buildFirstURL | func (s *ScrollService) buildFirstURL() (string, url.Values, error) {
// Build URL
var err error
var path string
if len(s.indices) == 0 && len(s.types) == 0 {
path = "/_search"
} else if len(s.indices) > 0 && len(s.types) == 0 {
path, err = uritemplates.Expand("/{index}/_search", map[string]string{
"index": strings.Join(s.indices, ","),
})
} else if len(s.indices) == 0 && len(s.types) > 0 {
path, err = uritemplates.Expand("/_all/{typ}/_search", map[string]string{
"typ": strings.Join(s.types, ","),
})
} else {
path, err = uritemplates.Expand("/{index}/{typ}/_search", map[string]string{
"index": strings.Join(s.indices, ","),
"typ": strings.Join(s.types, ","),
})
}
if err != nil {
return "", url.Values{}, err
}
// Add query string parameters
params := url.Values{}
if s.pretty {
params.Set("pretty", "true")
}
if s.size != nil && *s.size > 0 {
params.Set("size", fmt.Sprintf("%d", *s.size))
}
if len(s.keepAlive) > 0 {
params.Set("scroll", s.keepAlive)
}
if len(s.routing) > 0 {
params.Set("routing", s.routing)
}
if len(s.preference) > 0 {
params.Set("preference", s.preference)
}
if s.allowNoIndices != nil {
params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
}
if len(s.expandWildcards) > 0 {
params.Set("expand_wildcards", s.expandWildcards)
}
if s.ignoreUnavailable != nil {
params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
}
if len(s.filterPath) > 0 {
// Always add "hits._scroll_id", otherwise we cannot scroll
s.filterPath = append(s.filterPath, "_scroll_id")
params.Set("filter_path", strings.Join(s.filterPath, ","))
}
return path, params, nil
} | go | func (s *ScrollService) buildFirstURL() (string, url.Values, error) {
// Build URL
var err error
var path string
if len(s.indices) == 0 && len(s.types) == 0 {
path = "/_search"
} else if len(s.indices) > 0 && len(s.types) == 0 {
path, err = uritemplates.Expand("/{index}/_search", map[string]string{
"index": strings.Join(s.indices, ","),
})
} else if len(s.indices) == 0 && len(s.types) > 0 {
path, err = uritemplates.Expand("/_all/{typ}/_search", map[string]string{
"typ": strings.Join(s.types, ","),
})
} else {
path, err = uritemplates.Expand("/{index}/{typ}/_search", map[string]string{
"index": strings.Join(s.indices, ","),
"typ": strings.Join(s.types, ","),
})
}
if err != nil {
return "", url.Values{}, err
}
// Add query string parameters
params := url.Values{}
if s.pretty {
params.Set("pretty", "true")
}
if s.size != nil && *s.size > 0 {
params.Set("size", fmt.Sprintf("%d", *s.size))
}
if len(s.keepAlive) > 0 {
params.Set("scroll", s.keepAlive)
}
if len(s.routing) > 0 {
params.Set("routing", s.routing)
}
if len(s.preference) > 0 {
params.Set("preference", s.preference)
}
if s.allowNoIndices != nil {
params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
}
if len(s.expandWildcards) > 0 {
params.Set("expand_wildcards", s.expandWildcards)
}
if s.ignoreUnavailable != nil {
params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
}
if len(s.filterPath) > 0 {
// Always add "hits._scroll_id", otherwise we cannot scroll
s.filterPath = append(s.filterPath, "_scroll_id")
params.Set("filter_path", strings.Join(s.filterPath, ","))
}
return path, params, nil
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"buildFirstURL",
"(",
")",
"(",
"string",
",",
"url",
".",
"Values",
",",
"error",
")",
"{",
"// Build URL",
"var",
"err",
"error",
"\n",
"var",
"path",
"string",
"\n",
"if",
"len",
"(",
"s",
".",
"indices",
")",
"==",
"0",
"&&",
"len",
"(",
"s",
".",
"types",
")",
"==",
"0",
"{",
"path",
"=",
"\"",
"\"",
"\n",
"}",
"else",
"if",
"len",
"(",
"s",
".",
"indices",
")",
">",
"0",
"&&",
"len",
"(",
"s",
".",
"types",
")",
"==",
"0",
"{",
"path",
",",
"err",
"=",
"uritemplates",
".",
"Expand",
"(",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"strings",
".",
"Join",
"(",
"s",
".",
"indices",
",",
"\"",
"\"",
")",
",",
"}",
")",
"\n",
"}",
"else",
"if",
"len",
"(",
"s",
".",
"indices",
")",
"==",
"0",
"&&",
"len",
"(",
"s",
".",
"types",
")",
">",
"0",
"{",
"path",
",",
"err",
"=",
"uritemplates",
".",
"Expand",
"(",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"strings",
".",
"Join",
"(",
"s",
".",
"types",
",",
"\"",
"\"",
")",
",",
"}",
")",
"\n",
"}",
"else",
"{",
"path",
",",
"err",
"=",
"uritemplates",
".",
"Expand",
"(",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"strings",
".",
"Join",
"(",
"s",
".",
"indices",
",",
"\"",
"\"",
")",
",",
"\"",
"\"",
":",
"strings",
".",
"Join",
"(",
"s",
".",
"types",
",",
"\"",
"\"",
")",
",",
"}",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"url",
".",
"Values",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"// Add query string parameters",
"params",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"if",
"s",
".",
"pretty",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"size",
"!=",
"nil",
"&&",
"*",
"s",
".",
"size",
">",
"0",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"*",
"s",
".",
"size",
")",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"s",
".",
"keepAlive",
")",
">",
"0",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"s",
".",
"keepAlive",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"s",
".",
"routing",
")",
">",
"0",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"s",
".",
"routing",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"s",
".",
"preference",
")",
">",
"0",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"s",
".",
"preference",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"allowNoIndices",
"!=",
"nil",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"*",
"s",
".",
"allowNoIndices",
")",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"s",
".",
"expandWildcards",
")",
">",
"0",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"s",
".",
"expandWildcards",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"ignoreUnavailable",
"!=",
"nil",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"*",
"s",
".",
"ignoreUnavailable",
")",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"s",
".",
"filterPath",
")",
">",
"0",
"{",
"// Always add \"hits._scroll_id\", otherwise we cannot scroll",
"s",
".",
"filterPath",
"=",
"append",
"(",
"s",
".",
"filterPath",
",",
"\"",
"\"",
")",
"\n",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"s",
".",
"filterPath",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n\n",
"return",
"path",
",",
"params",
",",
"nil",
"\n",
"}"
] | // buildFirstURL builds the URL for retrieving the first page. | [
"buildFirstURL",
"builds",
"the",
"URL",
"for",
"retrieving",
"the",
"first",
"page",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L356-L413 | train |
olivere/elastic | scroll.go | bodyFirst | func (s *ScrollService) bodyFirst() (interface{}, error) {
var err error
var body interface{}
if s.body != nil {
body = s.body
} else {
// Use _doc sort by default if none is specified
if !s.ss.hasSort() {
// Use efficient sorting when no user-defined query/body is specified
s.ss = s.ss.SortBy(SortByDoc{})
}
// Body from search source
body, err = s.ss.Source()
if err != nil {
return nil, err
}
}
return body, nil
} | go | func (s *ScrollService) bodyFirst() (interface{}, error) {
var err error
var body interface{}
if s.body != nil {
body = s.body
} else {
// Use _doc sort by default if none is specified
if !s.ss.hasSort() {
// Use efficient sorting when no user-defined query/body is specified
s.ss = s.ss.SortBy(SortByDoc{})
}
// Body from search source
body, err = s.ss.Source()
if err != nil {
return nil, err
}
}
return body, nil
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"bodyFirst",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"body",
"interface",
"{",
"}",
"\n\n",
"if",
"s",
".",
"body",
"!=",
"nil",
"{",
"body",
"=",
"s",
".",
"body",
"\n",
"}",
"else",
"{",
"// Use _doc sort by default if none is specified",
"if",
"!",
"s",
".",
"ss",
".",
"hasSort",
"(",
")",
"{",
"// Use efficient sorting when no user-defined query/body is specified",
"s",
".",
"ss",
"=",
"s",
".",
"ss",
".",
"SortBy",
"(",
"SortByDoc",
"{",
"}",
")",
"\n",
"}",
"\n\n",
"// Body from search source",
"body",
",",
"err",
"=",
"s",
".",
"ss",
".",
"Source",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"body",
",",
"nil",
"\n",
"}"
] | // bodyFirst returns the request to fetch the first batch of results. | [
"bodyFirst",
"returns",
"the",
"request",
"to",
"fetch",
"the",
"first",
"batch",
"of",
"results",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L416-L437 | train |
olivere/elastic | scroll.go | buildNextURL | func (s *ScrollService) buildNextURL() (string, url.Values, error) {
path := "/_search/scroll"
// Add query string parameters
params := url.Values{}
if s.pretty {
params.Set("pretty", "true")
}
return path, params, nil
} | go | func (s *ScrollService) buildNextURL() (string, url.Values, error) {
path := "/_search/scroll"
// Add query string parameters
params := url.Values{}
if s.pretty {
params.Set("pretty", "true")
}
return path, params, nil
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"buildNextURL",
"(",
")",
"(",
"string",
",",
"url",
".",
"Values",
",",
"error",
")",
"{",
"path",
":=",
"\"",
"\"",
"\n\n",
"// Add query string parameters",
"params",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"if",
"s",
".",
"pretty",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"path",
",",
"params",
",",
"nil",
"\n",
"}"
] | // buildNextURL builds the URL for the operation. | [
"buildNextURL",
"builds",
"the",
"URL",
"for",
"the",
"operation",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L483-L493 | train |
olivere/elastic | scroll.go | bodyNext | func (s *ScrollService) bodyNext() (interface{}, error) {
s.mu.RLock()
body := struct {
Scroll string `json:"scroll"`
ScrollId string `json:"scroll_id,omitempty"`
}{
Scroll: s.keepAlive,
ScrollId: s.scrollId,
}
s.mu.RUnlock()
return body, nil
} | go | func (s *ScrollService) bodyNext() (interface{}, error) {
s.mu.RLock()
body := struct {
Scroll string `json:"scroll"`
ScrollId string `json:"scroll_id,omitempty"`
}{
Scroll: s.keepAlive,
ScrollId: s.scrollId,
}
s.mu.RUnlock()
return body, nil
} | [
"func",
"(",
"s",
"*",
"ScrollService",
")",
"bodyNext",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"body",
":=",
"struct",
"{",
"Scroll",
"string",
"`json:\"scroll\"`",
"\n",
"ScrollId",
"string",
"`json:\"scroll_id,omitempty\"`",
"\n",
"}",
"{",
"Scroll",
":",
"s",
".",
"keepAlive",
",",
"ScrollId",
":",
"s",
".",
"scrollId",
",",
"}",
"\n",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"body",
",",
"nil",
"\n",
"}"
] | // body returns the request to fetch the next batch of results. | [
"body",
"returns",
"the",
"request",
"to",
"fetch",
"the",
"next",
"batch",
"of",
"results",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/scroll.go#L496-L507 | train |
olivere/elastic | search_queries_match_none.go | Source | func (q MatchNoneQuery) Source() (interface{}, error) {
// {
// "match_none" : { ... }
// }
source := make(map[string]interface{})
params := make(map[string]interface{})
source["match_none"] = params
if q.queryName != "" {
params["_name"] = q.queryName
}
return source, nil
} | go | func (q MatchNoneQuery) Source() (interface{}, error) {
// {
// "match_none" : { ... }
// }
source := make(map[string]interface{})
params := make(map[string]interface{})
source["match_none"] = params
if q.queryName != "" {
params["_name"] = q.queryName
}
return source, nil
} | [
"func",
"(",
"q",
"MatchNoneQuery",
")",
"Source",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// {",
"// \"match_none\" : { ... }",
"// }",
"source",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"params",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"source",
"[",
"\"",
"\"",
"]",
"=",
"params",
"\n",
"if",
"q",
".",
"queryName",
"!=",
"\"",
"\"",
"{",
"params",
"[",
"\"",
"\"",
"]",
"=",
"q",
".",
"queryName",
"\n",
"}",
"\n",
"return",
"source",
",",
"nil",
"\n",
"}"
] | // Source returns JSON for the match none query. | [
"Source",
"returns",
"JSON",
"for",
"the",
"match",
"none",
"query",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_match_none.go#L28-L39 | train |
olivere/elastic | search_queries_prefix.go | NewPrefixQuery | func NewPrefixQuery(name string, prefix string) *PrefixQuery {
return &PrefixQuery{name: name, prefix: prefix}
} | go | func NewPrefixQuery(name string, prefix string) *PrefixQuery {
return &PrefixQuery{name: name, prefix: prefix}
} | [
"func",
"NewPrefixQuery",
"(",
"name",
"string",
",",
"prefix",
"string",
")",
"*",
"PrefixQuery",
"{",
"return",
"&",
"PrefixQuery",
"{",
"name",
":",
"name",
",",
"prefix",
":",
"prefix",
"}",
"\n",
"}"
] | // NewPrefixQuery creates and initializes a new PrefixQuery. | [
"NewPrefixQuery",
"creates",
"and",
"initializes",
"a",
"new",
"PrefixQuery",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_prefix.go#L21-L23 | train |
olivere/elastic | suggester_term.go | Source | func (q *TermSuggester) Source(includeName bool) (interface{}, error) {
// "suggest" : {
// "my-suggest-1" : {
// "text" : "the amsterdma meetpu",
// "term" : {
// "field" : "body"
// }
// },
// "my-suggest-2" : {
// "text" : "the rottredam meetpu",
// "term" : {
// "field" : "title",
// }
// }
// }
ts := &termSuggesterRequest{}
if q.text != "" {
ts.Text = q.text
}
suggester := make(map[string]interface{})
ts.Term = suggester
if q.analyzer != "" {
suggester["analyzer"] = q.analyzer
}
if q.field != "" {
suggester["field"] = q.field
}
if q.size != nil {
suggester["size"] = *q.size
}
if q.shardSize != nil {
suggester["shard_size"] = *q.shardSize
}
switch len(q.contextQueries) {
case 0:
case 1:
src, err := q.contextQueries[0].Source()
if err != nil {
return nil, err
}
suggester["contexts"] = src
default:
ctxq := make([]interface{}, len(q.contextQueries))
for i, query := range q.contextQueries {
src, err := query.Source()
if err != nil {
return nil, err
}
ctxq[i] = src
}
suggester["contexts"] = ctxq
}
// Specific to term suggester
if q.suggestMode != "" {
suggester["suggest_mode"] = q.suggestMode
}
if q.accuracy != nil {
suggester["accuracy"] = *q.accuracy
}
if q.sort != "" {
suggester["sort"] = q.sort
}
if q.stringDistance != "" {
suggester["string_distance"] = q.stringDistance
}
if q.maxEdits != nil {
suggester["max_edits"] = *q.maxEdits
}
if q.maxInspections != nil {
suggester["max_inspections"] = *q.maxInspections
}
if q.maxTermFreq != nil {
suggester["max_term_freq"] = *q.maxTermFreq
}
if q.prefixLength != nil {
suggester["prefix_length"] = *q.prefixLength
}
if q.minWordLength != nil {
suggester["min_word_len"] = *q.minWordLength
}
if q.minDocFreq != nil {
suggester["min_doc_freq"] = *q.minDocFreq
}
if !includeName {
return ts, nil
}
source := make(map[string]interface{})
source[q.name] = ts
return source, nil
} | go | func (q *TermSuggester) Source(includeName bool) (interface{}, error) {
// "suggest" : {
// "my-suggest-1" : {
// "text" : "the amsterdma meetpu",
// "term" : {
// "field" : "body"
// }
// },
// "my-suggest-2" : {
// "text" : "the rottredam meetpu",
// "term" : {
// "field" : "title",
// }
// }
// }
ts := &termSuggesterRequest{}
if q.text != "" {
ts.Text = q.text
}
suggester := make(map[string]interface{})
ts.Term = suggester
if q.analyzer != "" {
suggester["analyzer"] = q.analyzer
}
if q.field != "" {
suggester["field"] = q.field
}
if q.size != nil {
suggester["size"] = *q.size
}
if q.shardSize != nil {
suggester["shard_size"] = *q.shardSize
}
switch len(q.contextQueries) {
case 0:
case 1:
src, err := q.contextQueries[0].Source()
if err != nil {
return nil, err
}
suggester["contexts"] = src
default:
ctxq := make([]interface{}, len(q.contextQueries))
for i, query := range q.contextQueries {
src, err := query.Source()
if err != nil {
return nil, err
}
ctxq[i] = src
}
suggester["contexts"] = ctxq
}
// Specific to term suggester
if q.suggestMode != "" {
suggester["suggest_mode"] = q.suggestMode
}
if q.accuracy != nil {
suggester["accuracy"] = *q.accuracy
}
if q.sort != "" {
suggester["sort"] = q.sort
}
if q.stringDistance != "" {
suggester["string_distance"] = q.stringDistance
}
if q.maxEdits != nil {
suggester["max_edits"] = *q.maxEdits
}
if q.maxInspections != nil {
suggester["max_inspections"] = *q.maxInspections
}
if q.maxTermFreq != nil {
suggester["max_term_freq"] = *q.maxTermFreq
}
if q.prefixLength != nil {
suggester["prefix_length"] = *q.prefixLength
}
if q.minWordLength != nil {
suggester["min_word_len"] = *q.minWordLength
}
if q.minDocFreq != nil {
suggester["min_doc_freq"] = *q.minDocFreq
}
if !includeName {
return ts, nil
}
source := make(map[string]interface{})
source[q.name] = ts
return source, nil
} | [
"func",
"(",
"q",
"*",
"TermSuggester",
")",
"Source",
"(",
"includeName",
"bool",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// \"suggest\" : {",
"// \"my-suggest-1\" : {",
"// \"text\" : \"the amsterdma meetpu\",",
"// \"term\" : {",
"// \"field\" : \"body\"",
"// }",
"// },",
"// \"my-suggest-2\" : {",
"// \"text\" : \"the rottredam meetpu\",",
"// \"term\" : {",
"// \"field\" : \"title\",",
"// }",
"// }",
"// }",
"ts",
":=",
"&",
"termSuggesterRequest",
"{",
"}",
"\n",
"if",
"q",
".",
"text",
"!=",
"\"",
"\"",
"{",
"ts",
".",
"Text",
"=",
"q",
".",
"text",
"\n",
"}",
"\n\n",
"suggester",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"ts",
".",
"Term",
"=",
"suggester",
"\n\n",
"if",
"q",
".",
"analyzer",
"!=",
"\"",
"\"",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"q",
".",
"analyzer",
"\n",
"}",
"\n",
"if",
"q",
".",
"field",
"!=",
"\"",
"\"",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"q",
".",
"field",
"\n",
"}",
"\n",
"if",
"q",
".",
"size",
"!=",
"nil",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"*",
"q",
".",
"size",
"\n",
"}",
"\n",
"if",
"q",
".",
"shardSize",
"!=",
"nil",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"*",
"q",
".",
"shardSize",
"\n",
"}",
"\n",
"switch",
"len",
"(",
"q",
".",
"contextQueries",
")",
"{",
"case",
"0",
":",
"case",
"1",
":",
"src",
",",
"err",
":=",
"q",
".",
"contextQueries",
"[",
"0",
"]",
".",
"Source",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"src",
"\n",
"default",
":",
"ctxq",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"len",
"(",
"q",
".",
"contextQueries",
")",
")",
"\n",
"for",
"i",
",",
"query",
":=",
"range",
"q",
".",
"contextQueries",
"{",
"src",
",",
"err",
":=",
"query",
".",
"Source",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"ctxq",
"[",
"i",
"]",
"=",
"src",
"\n",
"}",
"\n",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"ctxq",
"\n",
"}",
"\n\n",
"// Specific to term suggester",
"if",
"q",
".",
"suggestMode",
"!=",
"\"",
"\"",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"q",
".",
"suggestMode",
"\n",
"}",
"\n",
"if",
"q",
".",
"accuracy",
"!=",
"nil",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"*",
"q",
".",
"accuracy",
"\n",
"}",
"\n",
"if",
"q",
".",
"sort",
"!=",
"\"",
"\"",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"q",
".",
"sort",
"\n",
"}",
"\n",
"if",
"q",
".",
"stringDistance",
"!=",
"\"",
"\"",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"q",
".",
"stringDistance",
"\n",
"}",
"\n",
"if",
"q",
".",
"maxEdits",
"!=",
"nil",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"*",
"q",
".",
"maxEdits",
"\n",
"}",
"\n",
"if",
"q",
".",
"maxInspections",
"!=",
"nil",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"*",
"q",
".",
"maxInspections",
"\n",
"}",
"\n",
"if",
"q",
".",
"maxTermFreq",
"!=",
"nil",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"*",
"q",
".",
"maxTermFreq",
"\n",
"}",
"\n",
"if",
"q",
".",
"prefixLength",
"!=",
"nil",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"*",
"q",
".",
"prefixLength",
"\n",
"}",
"\n",
"if",
"q",
".",
"minWordLength",
"!=",
"nil",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"*",
"q",
".",
"minWordLength",
"\n",
"}",
"\n",
"if",
"q",
".",
"minDocFreq",
"!=",
"nil",
"{",
"suggester",
"[",
"\"",
"\"",
"]",
"=",
"*",
"q",
".",
"minDocFreq",
"\n",
"}",
"\n\n",
"if",
"!",
"includeName",
"{",
"return",
"ts",
",",
"nil",
"\n",
"}",
"\n\n",
"source",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"source",
"[",
"q",
".",
"name",
"]",
"=",
"ts",
"\n",
"return",
"source",
",",
"nil",
"\n",
"}"
] | // Source generates the source for the term suggester. | [
"Source",
"generates",
"the",
"source",
"for",
"the",
"term",
"suggester",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/suggester_term.go#L139-L233 | train |
olivere/elastic | explain.go | NewExplainService | func NewExplainService(client *Client) *ExplainService {
return &ExplainService{
client: client,
typ: "_doc",
xSource: make([]string, 0),
xSourceExclude: make([]string, 0),
fields: make([]string, 0),
xSourceInclude: make([]string, 0),
}
} | go | func NewExplainService(client *Client) *ExplainService {
return &ExplainService{
client: client,
typ: "_doc",
xSource: make([]string, 0),
xSourceExclude: make([]string, 0),
fields: make([]string, 0),
xSourceInclude: make([]string, 0),
}
} | [
"func",
"NewExplainService",
"(",
"client",
"*",
"Client",
")",
"*",
"ExplainService",
"{",
"return",
"&",
"ExplainService",
"{",
"client",
":",
"client",
",",
"typ",
":",
"\"",
"\"",
",",
"xSource",
":",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
",",
"xSourceExclude",
":",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
",",
"fields",
":",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
",",
"xSourceInclude",
":",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
",",
"}",
"\n",
"}"
] | // NewExplainService creates a new ExplainService. | [
"NewExplainService",
"creates",
"a",
"new",
"ExplainService",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/explain.go#L45-L54 | train |
olivere/elastic | search_aggs_pipeline_serial_diff.go | Lag | func (a *SerialDiffAggregation) Lag(lag int) *SerialDiffAggregation {
a.lag = &lag
return a
} | go | func (a *SerialDiffAggregation) Lag(lag int) *SerialDiffAggregation {
a.lag = &lag
return a
} | [
"func",
"(",
"a",
"*",
"SerialDiffAggregation",
")",
"Lag",
"(",
"lag",
"int",
")",
"*",
"SerialDiffAggregation",
"{",
"a",
".",
"lag",
"=",
"&",
"lag",
"\n",
"return",
"a",
"\n",
"}"
] | // Lag specifies the historical bucket to subtract from the current value.
// E.g. a lag of 7 will subtract the current value from the value 7 buckets
// ago. Lag must be a positive, non-zero integer. | [
"Lag",
"specifies",
"the",
"historical",
"bucket",
"to",
"subtract",
"from",
"the",
"current",
"value",
".",
"E",
".",
"g",
".",
"a",
"lag",
"of",
"7",
"will",
"subtract",
"the",
"current",
"value",
"from",
"the",
"value",
"7",
"buckets",
"ago",
".",
"Lag",
"must",
"be",
"a",
"positive",
"non",
"-",
"zero",
"integer",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_aggs_pipeline_serial_diff.go#L57-L60 | train |
olivere/elastic | snapshot_verify_repository.go | Repository | func (s *SnapshotVerifyRepositoryService) Repository(repository string) *SnapshotVerifyRepositoryService {
s.repository = repository
return s
} | go | func (s *SnapshotVerifyRepositoryService) Repository(repository string) *SnapshotVerifyRepositoryService {
s.repository = repository
return s
} | [
"func",
"(",
"s",
"*",
"SnapshotVerifyRepositoryService",
")",
"Repository",
"(",
"repository",
"string",
")",
"*",
"SnapshotVerifyRepositoryService",
"{",
"s",
".",
"repository",
"=",
"repository",
"\n",
"return",
"s",
"\n",
"}"
] | // Repository specifies the repository name. | [
"Repository",
"specifies",
"the",
"repository",
"name",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/snapshot_verify_repository.go#L35-L38 | train |
olivere/elastic | search_aggs_bucket_adjacency_matrix.go | NewAdjacencyMatrixAggregation | func NewAdjacencyMatrixAggregation() *AdjacencyMatrixAggregation {
return &AdjacencyMatrixAggregation{
filters: make(map[string]Query),
subAggregations: make(map[string]Aggregation),
}
} | go | func NewAdjacencyMatrixAggregation() *AdjacencyMatrixAggregation {
return &AdjacencyMatrixAggregation{
filters: make(map[string]Query),
subAggregations: make(map[string]Aggregation),
}
} | [
"func",
"NewAdjacencyMatrixAggregation",
"(",
")",
"*",
"AdjacencyMatrixAggregation",
"{",
"return",
"&",
"AdjacencyMatrixAggregation",
"{",
"filters",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"Query",
")",
",",
"subAggregations",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"Aggregation",
")",
",",
"}",
"\n",
"}"
] | // NewAdjacencyMatrixAggregation initializes a new AdjacencyMatrixAggregation. | [
"NewAdjacencyMatrixAggregation",
"initializes",
"a",
"new",
"AdjacencyMatrixAggregation",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_aggs_bucket_adjacency_matrix.go#L21-L26 | train |
olivere/elastic | search_aggs_bucket_adjacency_matrix.go | Filters | func (a *AdjacencyMatrixAggregation) Filters(name string, filter Query) *AdjacencyMatrixAggregation {
a.filters[name] = filter
return a
} | go | func (a *AdjacencyMatrixAggregation) Filters(name string, filter Query) *AdjacencyMatrixAggregation {
a.filters[name] = filter
return a
} | [
"func",
"(",
"a",
"*",
"AdjacencyMatrixAggregation",
")",
"Filters",
"(",
"name",
"string",
",",
"filter",
"Query",
")",
"*",
"AdjacencyMatrixAggregation",
"{",
"a",
".",
"filters",
"[",
"name",
"]",
"=",
"filter",
"\n",
"return",
"a",
"\n",
"}"
] | // Filters adds the filter | [
"Filters",
"adds",
"the",
"filter"
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_aggs_bucket_adjacency_matrix.go#L29-L32 | train |
olivere/elastic | update_by_query.go | Index | func (s *UpdateByQueryService) Index(index ...string) *UpdateByQueryService {
s.index = append(s.index, index...)
return s
} | go | func (s *UpdateByQueryService) Index(index ...string) *UpdateByQueryService {
s.index = append(s.index, index...)
return s
} | [
"func",
"(",
"s",
"*",
"UpdateByQueryService",
")",
"Index",
"(",
"index",
"...",
"string",
")",
"*",
"UpdateByQueryService",
"{",
"s",
".",
"index",
"=",
"append",
"(",
"s",
".",
"index",
",",
"index",
"...",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // Index is a list of index names to search; use `_all` or empty string to
// perform the operation on all indices. | [
"Index",
"is",
"a",
"list",
"of",
"index",
"names",
"to",
"search",
";",
"use",
"_all",
"or",
"empty",
"string",
"to",
"perform",
"the",
"operation",
"on",
"all",
"indices",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update_by_query.go#L80-L83 | train |
olivere/elastic | update_by_query.go | Type | func (s *UpdateByQueryService) Type(typ ...string) *UpdateByQueryService {
s.typ = append(s.typ, typ...)
return s
} | go | func (s *UpdateByQueryService) Type(typ ...string) *UpdateByQueryService {
s.typ = append(s.typ, typ...)
return s
} | [
"func",
"(",
"s",
"*",
"UpdateByQueryService",
")",
"Type",
"(",
"typ",
"...",
"string",
")",
"*",
"UpdateByQueryService",
"{",
"s",
".",
"typ",
"=",
"append",
"(",
"s",
".",
"typ",
",",
"typ",
"...",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // Type is a list of document types to search; leave empty to perform
// the operation on all types. | [
"Type",
"is",
"a",
"list",
"of",
"document",
"types",
"to",
"search",
";",
"leave",
"empty",
"to",
"perform",
"the",
"operation",
"on",
"all",
"types",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update_by_query.go#L87-L90 | train |
olivere/elastic | update_by_query.go | Script | func (s *UpdateByQueryService) Script(script *Script) *UpdateByQueryService {
s.script = script
return s
} | go | func (s *UpdateByQueryService) Script(script *Script) *UpdateByQueryService {
s.script = script
return s
} | [
"func",
"(",
"s",
"*",
"UpdateByQueryService",
")",
"Script",
"(",
"script",
"*",
"Script",
")",
"*",
"UpdateByQueryService",
"{",
"s",
".",
"script",
"=",
"script",
"\n",
"return",
"s",
"\n",
"}"
] | // Script sets an update script. | [
"Script",
"sets",
"an",
"update",
"script",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update_by_query.go#L99-L102 | train |
olivere/elastic | update_by_query.go | Body | func (s *UpdateByQueryService) Body(body string) *UpdateByQueryService {
s.body = body
return s
} | go | func (s *UpdateByQueryService) Body(body string) *UpdateByQueryService {
s.body = body
return s
} | [
"func",
"(",
"s",
"*",
"UpdateByQueryService",
")",
"Body",
"(",
"body",
"string",
")",
"*",
"UpdateByQueryService",
"{",
"s",
".",
"body",
"=",
"body",
"\n",
"return",
"s",
"\n",
"}"
] | // Body specifies the body of the request. It overrides data being specified via
// SearchService or Script. | [
"Body",
"specifies",
"the",
"body",
"of",
"the",
"request",
".",
"It",
"overrides",
"data",
"being",
"specified",
"via",
"SearchService",
"or",
"Script",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update_by_query.go#L106-L109 | train |
olivere/elastic | update_by_query.go | DF | func (s *UpdateByQueryService) DF(df string) *UpdateByQueryService {
s.df = df
return s
} | go | func (s *UpdateByQueryService) DF(df string) *UpdateByQueryService {
s.df = df
return s
} | [
"func",
"(",
"s",
"*",
"UpdateByQueryService",
")",
"DF",
"(",
"df",
"string",
")",
"*",
"UpdateByQueryService",
"{",
"s",
".",
"df",
"=",
"df",
"\n",
"return",
"s",
"\n",
"}"
] | // DF specifies the field to use as default where no field prefix is given in the query string. | [
"DF",
"specifies",
"the",
"field",
"to",
"use",
"as",
"default",
"where",
"no",
"field",
"prefix",
"is",
"given",
"in",
"the",
"query",
"string",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update_by_query.go#L179-L182 | train |
olivere/elastic | update_by_query.go | FielddataFields | func (s *UpdateByQueryService) FielddataFields(fielddataFields ...string) *UpdateByQueryService {
s.fielddataFields = append(s.fielddataFields, fielddataFields...)
return s
} | go | func (s *UpdateByQueryService) FielddataFields(fielddataFields ...string) *UpdateByQueryService {
s.fielddataFields = append(s.fielddataFields, fielddataFields...)
return s
} | [
"func",
"(",
"s",
"*",
"UpdateByQueryService",
")",
"FielddataFields",
"(",
"fielddataFields",
"...",
"string",
")",
"*",
"UpdateByQueryService",
"{",
"s",
".",
"fielddataFields",
"=",
"append",
"(",
"s",
".",
"fielddataFields",
",",
"fielddataFields",
"...",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // FielddataFields is a list of fields to return as the field data
// representation of a field for each hit. | [
"FielddataFields",
"is",
"a",
"list",
"of",
"fields",
"to",
"return",
"as",
"the",
"field",
"data",
"representation",
"of",
"a",
"field",
"for",
"each",
"hit",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update_by_query.go#L206-L209 | train |
olivere/elastic | update_by_query.go | Q | func (s *UpdateByQueryService) Q(q string) *UpdateByQueryService {
s.q = q
return s
} | go | func (s *UpdateByQueryService) Q(q string) *UpdateByQueryService {
s.q = q
return s
} | [
"func",
"(",
"s",
"*",
"UpdateByQueryService",
")",
"Q",
"(",
"q",
"string",
")",
"*",
"UpdateByQueryService",
"{",
"s",
".",
"q",
"=",
"q",
"\n",
"return",
"s",
"\n",
"}"
] | // Q specifies the query in the Lucene query string syntax. | [
"Q",
"specifies",
"the",
"query",
"in",
"the",
"Lucene",
"query",
"string",
"syntax",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update_by_query.go#L251-L254 | train |
olivere/elastic | update_by_query.go | SortByField | func (s *UpdateByQueryService) SortByField(field string, ascending bool) *UpdateByQueryService {
if ascending {
s.sort = append(s.sort, fmt.Sprintf("%s:asc", field))
} else {
s.sort = append(s.sort, fmt.Sprintf("%s:desc", field))
}
return s
} | go | func (s *UpdateByQueryService) SortByField(field string, ascending bool) *UpdateByQueryService {
if ascending {
s.sort = append(s.sort, fmt.Sprintf("%s:asc", field))
} else {
s.sort = append(s.sort, fmt.Sprintf("%s:desc", field))
}
return s
} | [
"func",
"(",
"s",
"*",
"UpdateByQueryService",
")",
"SortByField",
"(",
"field",
"string",
",",
"ascending",
"bool",
")",
"*",
"UpdateByQueryService",
"{",
"if",
"ascending",
"{",
"s",
".",
"sort",
"=",
"append",
"(",
"s",
".",
"sort",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"field",
")",
")",
"\n",
"}",
"else",
"{",
"s",
".",
"sort",
"=",
"append",
"(",
"s",
".",
"sort",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"field",
")",
")",
"\n",
"}",
"\n",
"return",
"s",
"\n",
"}"
] | // SortByField adds a sort order. | [
"SortByField",
"adds",
"a",
"sort",
"order",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update_by_query.go#L341-L348 | train |
olivere/elastic | indices_freeze.go | Index | func (s *IndicesFreezeService) Index(index string) *IndicesFreezeService {
s.index = index
return s
} | go | func (s *IndicesFreezeService) Index(index string) *IndicesFreezeService {
s.index = index
return s
} | [
"func",
"(",
"s",
"*",
"IndicesFreezeService",
")",
"Index",
"(",
"index",
"string",
")",
"*",
"IndicesFreezeService",
"{",
"s",
".",
"index",
"=",
"index",
"\n",
"return",
"s",
"\n",
"}"
] | // Index is the name of the index to freeze. | [
"Index",
"is",
"the",
"name",
"of",
"the",
"index",
"to",
"freeze",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_freeze.go#L40-L43 | train |
olivere/elastic | termvectors.go | Id | func (s *TermvectorsService) Id(id string) *TermvectorsService {
s.id = id
return s
} | go | func (s *TermvectorsService) Id(id string) *TermvectorsService {
s.id = id
return s
} | [
"func",
"(",
"s",
"*",
"TermvectorsService",
")",
"Id",
"(",
"id",
"string",
")",
"*",
"TermvectorsService",
"{",
"s",
".",
"id",
"=",
"id",
"\n",
"return",
"s",
"\n",
"}"
] | // Id of the document. | [
"Id",
"of",
"the",
"document",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/termvectors.go#L70-L73 | train |
olivere/elastic | termvectors.go | Dfs | func (s *TermvectorsService) Dfs(dfs bool) *TermvectorsService {
s.dfs = &dfs
return s
} | go | func (s *TermvectorsService) Dfs(dfs bool) *TermvectorsService {
s.dfs = &dfs
return s
} | [
"func",
"(",
"s",
"*",
"TermvectorsService",
")",
"Dfs",
"(",
"dfs",
"bool",
")",
"*",
"TermvectorsService",
"{",
"s",
".",
"dfs",
"=",
"&",
"dfs",
"\n",
"return",
"s",
"\n",
"}"
] | // Dfs specifies if distributed frequencies should be returned instead
// shard frequencies. | [
"Dfs",
"specifies",
"if",
"distributed",
"frequencies",
"should",
"be",
"returned",
"instead",
"shard",
"frequencies",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/termvectors.go#L77-L80 | train |
olivere/elastic | termvectors.go | Filter | func (s *TermvectorsService) Filter(filter *TermvectorsFilterSettings) *TermvectorsService {
s.filter = filter
return s
} | go | func (s *TermvectorsService) Filter(filter *TermvectorsFilterSettings) *TermvectorsService {
s.filter = filter
return s
} | [
"func",
"(",
"s",
"*",
"TermvectorsService",
")",
"Filter",
"(",
"filter",
"*",
"TermvectorsFilterSettings",
")",
"*",
"TermvectorsService",
"{",
"s",
".",
"filter",
"=",
"filter",
"\n",
"return",
"s",
"\n",
"}"
] | // Filter adds terms filter settings. | [
"Filter",
"adds",
"terms",
"filter",
"settings",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/termvectors.go#L105-L108 | train |
olivere/elastic | termvectors.go | BodyString | func (s *TermvectorsService) BodyString(body string) *TermvectorsService {
s.bodyString = body
return s
} | go | func (s *TermvectorsService) BodyString(body string) *TermvectorsService {
s.bodyString = body
return s
} | [
"func",
"(",
"s",
"*",
"TermvectorsService",
")",
"BodyString",
"(",
"body",
"string",
")",
"*",
"TermvectorsService",
"{",
"s",
".",
"bodyString",
"=",
"body",
"\n",
"return",
"s",
"\n",
"}"
] | // BodyString defines the body parameters as a string. See documentation. | [
"BodyString",
"defines",
"the",
"body",
"parameters",
"as",
"a",
"string",
".",
"See",
"documentation",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/termvectors.go#L193-L196 | train |
olivere/elastic | termvectors.go | MaxNumTerms | func (fs *TermvectorsFilterSettings) MaxNumTerms(value int64) *TermvectorsFilterSettings {
fs.maxNumTerms = &value
return fs
} | go | func (fs *TermvectorsFilterSettings) MaxNumTerms(value int64) *TermvectorsFilterSettings {
fs.maxNumTerms = &value
return fs
} | [
"func",
"(",
"fs",
"*",
"TermvectorsFilterSettings",
")",
"MaxNumTerms",
"(",
"value",
"int64",
")",
"*",
"TermvectorsFilterSettings",
"{",
"fs",
".",
"maxNumTerms",
"=",
"&",
"value",
"\n",
"return",
"fs",
"\n",
"}"
] | // MaxNumTerms specifies the maximum number of terms the must be returned per field. | [
"MaxNumTerms",
"specifies",
"the",
"maximum",
"number",
"of",
"terms",
"the",
"must",
"be",
"returned",
"per",
"field",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/termvectors.go#L367-L370 | train |
olivere/elastic | termvectors.go | MinTermFreq | func (fs *TermvectorsFilterSettings) MinTermFreq(value int64) *TermvectorsFilterSettings {
fs.minTermFreq = &value
return fs
} | go | func (fs *TermvectorsFilterSettings) MinTermFreq(value int64) *TermvectorsFilterSettings {
fs.minTermFreq = &value
return fs
} | [
"func",
"(",
"fs",
"*",
"TermvectorsFilterSettings",
")",
"MinTermFreq",
"(",
"value",
"int64",
")",
"*",
"TermvectorsFilterSettings",
"{",
"fs",
".",
"minTermFreq",
"=",
"&",
"value",
"\n",
"return",
"fs",
"\n",
"}"
] | // MinTermFreq ignores words with less than this frequency in the source doc. | [
"MinTermFreq",
"ignores",
"words",
"with",
"less",
"than",
"this",
"frequency",
"in",
"the",
"source",
"doc",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/termvectors.go#L373-L376 | train |
olivere/elastic | termvectors.go | MaxTermFreq | func (fs *TermvectorsFilterSettings) MaxTermFreq(value int64) *TermvectorsFilterSettings {
fs.maxTermFreq = &value
return fs
} | go | func (fs *TermvectorsFilterSettings) MaxTermFreq(value int64) *TermvectorsFilterSettings {
fs.maxTermFreq = &value
return fs
} | [
"func",
"(",
"fs",
"*",
"TermvectorsFilterSettings",
")",
"MaxTermFreq",
"(",
"value",
"int64",
")",
"*",
"TermvectorsFilterSettings",
"{",
"fs",
".",
"maxTermFreq",
"=",
"&",
"value",
"\n",
"return",
"fs",
"\n",
"}"
] | // MaxTermFreq ignores words with more than this frequency in the source doc. | [
"MaxTermFreq",
"ignores",
"words",
"with",
"more",
"than",
"this",
"frequency",
"in",
"the",
"source",
"doc",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/termvectors.go#L379-L382 | train |
olivere/elastic | termvectors.go | MinDocFreq | func (fs *TermvectorsFilterSettings) MinDocFreq(value int64) *TermvectorsFilterSettings {
fs.minDocFreq = &value
return fs
} | go | func (fs *TermvectorsFilterSettings) MinDocFreq(value int64) *TermvectorsFilterSettings {
fs.minDocFreq = &value
return fs
} | [
"func",
"(",
"fs",
"*",
"TermvectorsFilterSettings",
")",
"MinDocFreq",
"(",
"value",
"int64",
")",
"*",
"TermvectorsFilterSettings",
"{",
"fs",
".",
"minDocFreq",
"=",
"&",
"value",
"\n",
"return",
"fs",
"\n",
"}"
] | // MinDocFreq ignores terms which do not occur in at least this many docs. | [
"MinDocFreq",
"ignores",
"terms",
"which",
"do",
"not",
"occur",
"in",
"at",
"least",
"this",
"many",
"docs",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/termvectors.go#L385-L388 | train |
olivere/elastic | termvectors.go | MaxDocFreq | func (fs *TermvectorsFilterSettings) MaxDocFreq(value int64) *TermvectorsFilterSettings {
fs.maxDocFreq = &value
return fs
} | go | func (fs *TermvectorsFilterSettings) MaxDocFreq(value int64) *TermvectorsFilterSettings {
fs.maxDocFreq = &value
return fs
} | [
"func",
"(",
"fs",
"*",
"TermvectorsFilterSettings",
")",
"MaxDocFreq",
"(",
"value",
"int64",
")",
"*",
"TermvectorsFilterSettings",
"{",
"fs",
".",
"maxDocFreq",
"=",
"&",
"value",
"\n",
"return",
"fs",
"\n",
"}"
] | // MaxDocFreq ignores terms which occur in more than this many docs. | [
"MaxDocFreq",
"ignores",
"terms",
"which",
"occur",
"in",
"more",
"than",
"this",
"many",
"docs",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/termvectors.go#L391-L394 | train |
olivere/elastic | termvectors.go | MinWordLength | func (fs *TermvectorsFilterSettings) MinWordLength(value int64) *TermvectorsFilterSettings {
fs.minWordLength = &value
return fs
} | go | func (fs *TermvectorsFilterSettings) MinWordLength(value int64) *TermvectorsFilterSettings {
fs.minWordLength = &value
return fs
} | [
"func",
"(",
"fs",
"*",
"TermvectorsFilterSettings",
")",
"MinWordLength",
"(",
"value",
"int64",
")",
"*",
"TermvectorsFilterSettings",
"{",
"fs",
".",
"minWordLength",
"=",
"&",
"value",
"\n",
"return",
"fs",
"\n",
"}"
] | // MinWordLength specifies the minimum word length below which words will be ignored. | [
"MinWordLength",
"specifies",
"the",
"minimum",
"word",
"length",
"below",
"which",
"words",
"will",
"be",
"ignored",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/termvectors.go#L397-L400 | train |
olivere/elastic | termvectors.go | MaxWordLength | func (fs *TermvectorsFilterSettings) MaxWordLength(value int64) *TermvectorsFilterSettings {
fs.maxWordLength = &value
return fs
} | go | func (fs *TermvectorsFilterSettings) MaxWordLength(value int64) *TermvectorsFilterSettings {
fs.maxWordLength = &value
return fs
} | [
"func",
"(",
"fs",
"*",
"TermvectorsFilterSettings",
")",
"MaxWordLength",
"(",
"value",
"int64",
")",
"*",
"TermvectorsFilterSettings",
"{",
"fs",
".",
"maxWordLength",
"=",
"&",
"value",
"\n",
"return",
"fs",
"\n",
"}"
] | // MaxWordLength specifies the maximum word length above which words will be ignored. | [
"MaxWordLength",
"specifies",
"the",
"maximum",
"word",
"length",
"above",
"which",
"words",
"will",
"be",
"ignored",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/termvectors.go#L403-L406 | train |
olivere/elastic | snapshot_delete_repository.go | NewSnapshotDeleteRepositoryService | func NewSnapshotDeleteRepositoryService(client *Client) *SnapshotDeleteRepositoryService {
return &SnapshotDeleteRepositoryService{
client: client,
repository: make([]string, 0),
}
} | go | func NewSnapshotDeleteRepositoryService(client *Client) *SnapshotDeleteRepositoryService {
return &SnapshotDeleteRepositoryService{
client: client,
repository: make([]string, 0),
}
} | [
"func",
"NewSnapshotDeleteRepositoryService",
"(",
"client",
"*",
"Client",
")",
"*",
"SnapshotDeleteRepositoryService",
"{",
"return",
"&",
"SnapshotDeleteRepositoryService",
"{",
"client",
":",
"client",
",",
"repository",
":",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
",",
"}",
"\n",
"}"
] | // NewSnapshotDeleteRepositoryService creates a new SnapshotDeleteRepositoryService. | [
"NewSnapshotDeleteRepositoryService",
"creates",
"a",
"new",
"SnapshotDeleteRepositoryService",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/snapshot_delete_repository.go#L29-L34 | train |
olivere/elastic | update.go | Routing | func (b *UpdateService) Routing(routing string) *UpdateService {
b.routing = routing
return b
} | go | func (b *UpdateService) Routing(routing string) *UpdateService {
b.routing = routing
return b
} | [
"func",
"(",
"b",
"*",
"UpdateService",
")",
"Routing",
"(",
"routing",
"string",
")",
"*",
"UpdateService",
"{",
"b",
".",
"routing",
"=",
"routing",
"\n",
"return",
"b",
"\n",
"}"
] | // Routing specifies a specific routing value. | [
"Routing",
"specifies",
"a",
"specific",
"routing",
"value",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update.go#L74-L77 | train |
olivere/elastic | update.go | Parent | func (b *UpdateService) Parent(parent string) *UpdateService {
b.parent = parent
return b
} | go | func (b *UpdateService) Parent(parent string) *UpdateService {
b.parent = parent
return b
} | [
"func",
"(",
"b",
"*",
"UpdateService",
")",
"Parent",
"(",
"parent",
"string",
")",
"*",
"UpdateService",
"{",
"b",
".",
"parent",
"=",
"parent",
"\n",
"return",
"b",
"\n",
"}"
] | // Parent sets the id of the parent document. | [
"Parent",
"sets",
"the",
"id",
"of",
"the",
"parent",
"document",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update.go#L80-L83 | train |
olivere/elastic | update.go | Script | func (b *UpdateService) Script(script *Script) *UpdateService {
b.script = script
return b
} | go | func (b *UpdateService) Script(script *Script) *UpdateService {
b.script = script
return b
} | [
"func",
"(",
"b",
"*",
"UpdateService",
")",
"Script",
"(",
"script",
"*",
"Script",
")",
"*",
"UpdateService",
"{",
"b",
".",
"script",
"=",
"script",
"\n",
"return",
"b",
"\n",
"}"
] | // Script is the script definition. | [
"Script",
"is",
"the",
"script",
"definition",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update.go#L86-L89 | train |
olivere/elastic | update.go | Version | func (b *UpdateService) Version(version int64) *UpdateService {
b.version = &version
return b
} | go | func (b *UpdateService) Version(version int64) *UpdateService {
b.version = &version
return b
} | [
"func",
"(",
"b",
"*",
"UpdateService",
")",
"Version",
"(",
"version",
"int64",
")",
"*",
"UpdateService",
"{",
"b",
".",
"version",
"=",
"&",
"version",
"\n",
"return",
"b",
"\n",
"}"
] | // Version defines the explicit version number for concurrency control. | [
"Version",
"defines",
"the",
"explicit",
"version",
"number",
"for",
"concurrency",
"control",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update.go#L106-L109 | train |
olivere/elastic | update.go | DocAsUpsert | func (b *UpdateService) DocAsUpsert(docAsUpsert bool) *UpdateService {
b.docAsUpsert = &docAsUpsert
return b
} | go | func (b *UpdateService) DocAsUpsert(docAsUpsert bool) *UpdateService {
b.docAsUpsert = &docAsUpsert
return b
} | [
"func",
"(",
"b",
"*",
"UpdateService",
")",
"DocAsUpsert",
"(",
"docAsUpsert",
"bool",
")",
"*",
"UpdateService",
"{",
"b",
".",
"docAsUpsert",
"=",
"&",
"docAsUpsert",
"\n",
"return",
"b",
"\n",
"}"
] | // DocAsUpsert can be used to insert the document if it doesn't already exist. | [
"DocAsUpsert",
"can",
"be",
"used",
"to",
"insert",
"the",
"document",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update.go#L149-L152 | train |
olivere/elastic | update.go | DetectNoop | func (b *UpdateService) DetectNoop(detectNoop bool) *UpdateService {
b.detectNoop = &detectNoop
return b
} | go | func (b *UpdateService) DetectNoop(detectNoop bool) *UpdateService {
b.detectNoop = &detectNoop
return b
} | [
"func",
"(",
"b",
"*",
"UpdateService",
")",
"DetectNoop",
"(",
"detectNoop",
"bool",
")",
"*",
"UpdateService",
"{",
"b",
".",
"detectNoop",
"=",
"&",
"detectNoop",
"\n",
"return",
"b",
"\n",
"}"
] | // DetectNoop will instruct Elasticsearch to check if changes will occur
// when updating via Doc. It there aren't any changes, the request will
// turn into a no-op. | [
"DetectNoop",
"will",
"instruct",
"Elasticsearch",
"to",
"check",
"if",
"changes",
"will",
"occur",
"when",
"updating",
"via",
"Doc",
".",
"It",
"there",
"aren",
"t",
"any",
"changes",
"the",
"request",
"will",
"turn",
"into",
"a",
"no",
"-",
"op",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update.go#L157-L160 | train |
olivere/elastic | update.go | Pretty | func (b *UpdateService) Pretty(pretty bool) *UpdateService {
b.pretty = pretty
return b
} | go | func (b *UpdateService) Pretty(pretty bool) *UpdateService {
b.pretty = pretty
return b
} | [
"func",
"(",
"b",
"*",
"UpdateService",
")",
"Pretty",
"(",
"pretty",
"bool",
")",
"*",
"UpdateService",
"{",
"b",
".",
"pretty",
"=",
"pretty",
"\n",
"return",
"b",
"\n",
"}"
] | // Pretty instructs to return human readable, prettified JSON. | [
"Pretty",
"instructs",
"to",
"return",
"human",
"readable",
"prettified",
"JSON",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update.go#L177-L180 | train |
olivere/elastic | update.go | FetchSourceContext | func (s *UpdateService) FetchSourceContext(fetchSourceContext *FetchSourceContext) *UpdateService {
s.fsc = fetchSourceContext
return s
} | go | func (s *UpdateService) FetchSourceContext(fetchSourceContext *FetchSourceContext) *UpdateService {
s.fsc = fetchSourceContext
return s
} | [
"func",
"(",
"s",
"*",
"UpdateService",
")",
"FetchSourceContext",
"(",
"fetchSourceContext",
"*",
"FetchSourceContext",
")",
"*",
"UpdateService",
"{",
"s",
".",
"fsc",
"=",
"fetchSourceContext",
"\n",
"return",
"s",
"\n",
"}"
] | // FetchSourceContext indicates that _source should be returned in the response,
// allowing wildcard patterns to be defined via FetchSourceContext. | [
"FetchSourceContext",
"indicates",
"that",
"_source",
"should",
"be",
"returned",
"in",
"the",
"response",
"allowing",
"wildcard",
"patterns",
"to",
"be",
"defined",
"via",
"FetchSourceContext",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update.go#L194-L197 | train |
olivere/elastic | update.go | url | func (b *UpdateService) url() (string, url.Values, error) {
// Build url
var path string
var err error
if b.typ == "_doc" {
path, err = uritemplates.Expand("/{index}/_update/{id}", map[string]string{
"index": b.index,
"id": b.id,
})
} else {
path, err = uritemplates.Expand("/{index}/{type}/{id}/_update", map[string]string{
"index": b.index,
"type": b.typ,
"id": b.id,
})
}
if err != nil {
return "", url.Values{}, err
}
// Parameters
params := make(url.Values)
if b.pretty {
params.Set("pretty", "true")
}
if b.routing != "" {
params.Set("routing", b.routing)
}
if b.parent != "" {
params.Set("parent", b.parent)
}
if b.timeout != "" {
params.Set("timeout", b.timeout)
}
if b.refresh != "" {
params.Set("refresh", b.refresh)
}
if b.waitForActiveShards != "" {
params.Set("wait_for_active_shards", b.waitForActiveShards)
}
if len(b.fields) > 0 {
params.Set("fields", strings.Join(b.fields, ","))
}
if b.version != nil {
params.Set("version", fmt.Sprintf("%d", *b.version))
}
if b.versionType != "" {
params.Set("version_type", b.versionType)
}
if b.retryOnConflict != nil {
params.Set("retry_on_conflict", fmt.Sprintf("%v", *b.retryOnConflict))
}
return path, params, nil
} | go | func (b *UpdateService) url() (string, url.Values, error) {
// Build url
var path string
var err error
if b.typ == "_doc" {
path, err = uritemplates.Expand("/{index}/_update/{id}", map[string]string{
"index": b.index,
"id": b.id,
})
} else {
path, err = uritemplates.Expand("/{index}/{type}/{id}/_update", map[string]string{
"index": b.index,
"type": b.typ,
"id": b.id,
})
}
if err != nil {
return "", url.Values{}, err
}
// Parameters
params := make(url.Values)
if b.pretty {
params.Set("pretty", "true")
}
if b.routing != "" {
params.Set("routing", b.routing)
}
if b.parent != "" {
params.Set("parent", b.parent)
}
if b.timeout != "" {
params.Set("timeout", b.timeout)
}
if b.refresh != "" {
params.Set("refresh", b.refresh)
}
if b.waitForActiveShards != "" {
params.Set("wait_for_active_shards", b.waitForActiveShards)
}
if len(b.fields) > 0 {
params.Set("fields", strings.Join(b.fields, ","))
}
if b.version != nil {
params.Set("version", fmt.Sprintf("%d", *b.version))
}
if b.versionType != "" {
params.Set("version_type", b.versionType)
}
if b.retryOnConflict != nil {
params.Set("retry_on_conflict", fmt.Sprintf("%v", *b.retryOnConflict))
}
return path, params, nil
} | [
"func",
"(",
"b",
"*",
"UpdateService",
")",
"url",
"(",
")",
"(",
"string",
",",
"url",
".",
"Values",
",",
"error",
")",
"{",
"// Build url",
"var",
"path",
"string",
"\n",
"var",
"err",
"error",
"\n",
"if",
"b",
".",
"typ",
"==",
"\"",
"\"",
"{",
"path",
",",
"err",
"=",
"uritemplates",
".",
"Expand",
"(",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"b",
".",
"index",
",",
"\"",
"\"",
":",
"b",
".",
"id",
",",
"}",
")",
"\n",
"}",
"else",
"{",
"path",
",",
"err",
"=",
"uritemplates",
".",
"Expand",
"(",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"b",
".",
"index",
",",
"\"",
"\"",
":",
"b",
".",
"typ",
",",
"\"",
"\"",
":",
"b",
".",
"id",
",",
"}",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"url",
".",
"Values",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"// Parameters",
"params",
":=",
"make",
"(",
"url",
".",
"Values",
")",
"\n",
"if",
"b",
".",
"pretty",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"b",
".",
"routing",
"!=",
"\"",
"\"",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"b",
".",
"routing",
")",
"\n",
"}",
"\n",
"if",
"b",
".",
"parent",
"!=",
"\"",
"\"",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"b",
".",
"parent",
")",
"\n",
"}",
"\n",
"if",
"b",
".",
"timeout",
"!=",
"\"",
"\"",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"b",
".",
"timeout",
")",
"\n",
"}",
"\n",
"if",
"b",
".",
"refresh",
"!=",
"\"",
"\"",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"b",
".",
"refresh",
")",
"\n",
"}",
"\n",
"if",
"b",
".",
"waitForActiveShards",
"!=",
"\"",
"\"",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"b",
".",
"waitForActiveShards",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"b",
".",
"fields",
")",
">",
"0",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"b",
".",
"fields",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"if",
"b",
".",
"version",
"!=",
"nil",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"*",
"b",
".",
"version",
")",
")",
"\n",
"}",
"\n",
"if",
"b",
".",
"versionType",
"!=",
"\"",
"\"",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"b",
".",
"versionType",
")",
"\n",
"}",
"\n",
"if",
"b",
".",
"retryOnConflict",
"!=",
"nil",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"*",
"b",
".",
"retryOnConflict",
")",
")",
"\n",
"}",
"\n\n",
"return",
"path",
",",
"params",
",",
"nil",
"\n",
"}"
] | // url returns the URL part of the document request. | [
"url",
"returns",
"the",
"URL",
"part",
"of",
"the",
"document",
"request",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/update.go#L200-L254 | train |
olivere/elastic | bulk.go | Reset | func (s *BulkService) Reset() {
s.requests = make([]BulkableRequest, 0)
s.sizeInBytes = 0
s.sizeInBytesCursor = 0
} | go | func (s *BulkService) Reset() {
s.requests = make([]BulkableRequest, 0)
s.sizeInBytes = 0
s.sizeInBytesCursor = 0
} | [
"func",
"(",
"s",
"*",
"BulkService",
")",
"Reset",
"(",
")",
"{",
"s",
".",
"requests",
"=",
"make",
"(",
"[",
"]",
"BulkableRequest",
",",
"0",
")",
"\n",
"s",
".",
"sizeInBytes",
"=",
"0",
"\n",
"s",
".",
"sizeInBytesCursor",
"=",
"0",
"\n",
"}"
] | // Reset cleans up the request queue | [
"Reset",
"cleans",
"up",
"the",
"request",
"queue"
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk.go#L56-L60 | train |
olivere/elastic | bulk.go | Retrier | func (s *BulkService) Retrier(retrier Retrier) *BulkService {
s.retrier = retrier
return s
} | go | func (s *BulkService) Retrier(retrier Retrier) *BulkService {
s.retrier = retrier
return s
} | [
"func",
"(",
"s",
"*",
"BulkService",
")",
"Retrier",
"(",
"retrier",
"Retrier",
")",
"*",
"BulkService",
"{",
"s",
".",
"retrier",
"=",
"retrier",
"\n",
"return",
"s",
"\n",
"}"
] | // Retrier allows to set specific retry logic for this BulkService.
// If not specified, it will use the client's default retrier. | [
"Retrier",
"allows",
"to",
"set",
"specific",
"retry",
"logic",
"for",
"this",
"BulkService",
".",
"If",
"not",
"specified",
"it",
"will",
"use",
"the",
"client",
"s",
"default",
"retrier",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk.go#L64-L67 | train |
olivere/elastic | bulk.go | Index | func (s *BulkService) Index(index string) *BulkService {
s.index = index
return s
} | go | func (s *BulkService) Index(index string) *BulkService {
s.index = index
return s
} | [
"func",
"(",
"s",
"*",
"BulkService",
")",
"Index",
"(",
"index",
"string",
")",
"*",
"BulkService",
"{",
"s",
".",
"index",
"=",
"index",
"\n",
"return",
"s",
"\n",
"}"
] | // Index specifies the index to use for all batches. You may also leave
// this blank and specify the index in the individual bulk requests. | [
"Index",
"specifies",
"the",
"index",
"to",
"use",
"for",
"all",
"batches",
".",
"You",
"may",
"also",
"leave",
"this",
"blank",
"and",
"specify",
"the",
"index",
"in",
"the",
"individual",
"bulk",
"requests",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk.go#L71-L74 | train |
olivere/elastic | bulk.go | Type | func (s *BulkService) Type(typ string) *BulkService {
s.typ = typ
return s
} | go | func (s *BulkService) Type(typ string) *BulkService {
s.typ = typ
return s
} | [
"func",
"(",
"s",
"*",
"BulkService",
")",
"Type",
"(",
"typ",
"string",
")",
"*",
"BulkService",
"{",
"s",
".",
"typ",
"=",
"typ",
"\n",
"return",
"s",
"\n",
"}"
] | // Type specifies the type to use for all batches. You may also leave
// this blank and specify the type in the individual bulk requests. | [
"Type",
"specifies",
"the",
"type",
"to",
"use",
"for",
"all",
"batches",
".",
"You",
"may",
"also",
"leave",
"this",
"blank",
"and",
"specify",
"the",
"type",
"in",
"the",
"individual",
"bulk",
"requests",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk.go#L78-L81 | train |
olivere/elastic | bulk.go | Timeout | func (s *BulkService) Timeout(timeout string) *BulkService {
s.timeout = timeout
return s
} | go | func (s *BulkService) Timeout(timeout string) *BulkService {
s.timeout = timeout
return s
} | [
"func",
"(",
"s",
"*",
"BulkService",
")",
"Timeout",
"(",
"timeout",
"string",
")",
"*",
"BulkService",
"{",
"s",
".",
"timeout",
"=",
"timeout",
"\n",
"return",
"s",
"\n",
"}"
] | // Timeout is a global timeout for processing bulk requests. This is a
// server-side timeout, i.e. it tells Elasticsearch the time after which
// it should stop processing. | [
"Timeout",
"is",
"a",
"global",
"timeout",
"for",
"processing",
"bulk",
"requests",
".",
"This",
"is",
"a",
"server",
"-",
"side",
"timeout",
"i",
".",
"e",
".",
"it",
"tells",
"Elasticsearch",
"the",
"time",
"after",
"which",
"it",
"should",
"stop",
"processing",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk.go#L86-L89 | train |
olivere/elastic | bulk.go | Pretty | func (s *BulkService) Pretty(pretty bool) *BulkService {
s.pretty = pretty
return s
} | go | func (s *BulkService) Pretty(pretty bool) *BulkService {
s.pretty = pretty
return s
} | [
"func",
"(",
"s",
"*",
"BulkService",
")",
"Pretty",
"(",
"pretty",
"bool",
")",
"*",
"BulkService",
"{",
"s",
".",
"pretty",
"=",
"pretty",
"\n",
"return",
"s",
"\n",
"}"
] | // Pretty tells Elasticsearch whether to return a formatted JSON response. | [
"Pretty",
"tells",
"Elasticsearch",
"whether",
"to",
"return",
"a",
"formatted",
"JSON",
"response",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk.go#L127-L130 | train |
olivere/elastic | bulk.go | EstimatedSizeInBytes | func (s *BulkService) EstimatedSizeInBytes() int64 {
if s.sizeInBytesCursor == len(s.requests) {
return s.sizeInBytes
}
for _, r := range s.requests[s.sizeInBytesCursor:] {
s.sizeInBytes += s.estimateSizeInBytes(r)
s.sizeInBytesCursor++
}
return s.sizeInBytes
} | go | func (s *BulkService) EstimatedSizeInBytes() int64 {
if s.sizeInBytesCursor == len(s.requests) {
return s.sizeInBytes
}
for _, r := range s.requests[s.sizeInBytesCursor:] {
s.sizeInBytes += s.estimateSizeInBytes(r)
s.sizeInBytesCursor++
}
return s.sizeInBytes
} | [
"func",
"(",
"s",
"*",
"BulkService",
")",
"EstimatedSizeInBytes",
"(",
")",
"int64",
"{",
"if",
"s",
".",
"sizeInBytesCursor",
"==",
"len",
"(",
"s",
".",
"requests",
")",
"{",
"return",
"s",
".",
"sizeInBytes",
"\n",
"}",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"s",
".",
"requests",
"[",
"s",
".",
"sizeInBytesCursor",
":",
"]",
"{",
"s",
".",
"sizeInBytes",
"+=",
"s",
".",
"estimateSizeInBytes",
"(",
"r",
")",
"\n",
"s",
".",
"sizeInBytesCursor",
"++",
"\n",
"}",
"\n",
"return",
"s",
".",
"sizeInBytes",
"\n",
"}"
] | // EstimatedSizeInBytes returns the estimated size of all bulkable
// requests added via Add. | [
"EstimatedSizeInBytes",
"returns",
"the",
"estimated",
"size",
"of",
"all",
"bulkable",
"requests",
"added",
"via",
"Add",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk.go#L143-L152 | train |
olivere/elastic | bulk.go | estimateSizeInBytes | func (s *BulkService) estimateSizeInBytes(r BulkableRequest) int64 {
lines, _ := r.Source()
size := 0
for _, line := range lines {
// +1 for the \n
size += len(line) + 1
}
return int64(size)
} | go | func (s *BulkService) estimateSizeInBytes(r BulkableRequest) int64 {
lines, _ := r.Source()
size := 0
for _, line := range lines {
// +1 for the \n
size += len(line) + 1
}
return int64(size)
} | [
"func",
"(",
"s",
"*",
"BulkService",
")",
"estimateSizeInBytes",
"(",
"r",
"BulkableRequest",
")",
"int64",
"{",
"lines",
",",
"_",
":=",
"r",
".",
"Source",
"(",
")",
"\n",
"size",
":=",
"0",
"\n",
"for",
"_",
",",
"line",
":=",
"range",
"lines",
"{",
"// +1 for the \\n",
"size",
"+=",
"len",
"(",
"line",
")",
"+",
"1",
"\n",
"}",
"\n",
"return",
"int64",
"(",
"size",
")",
"\n",
"}"
] | // estimateSizeInBytes returns the estimates size of the given
// bulkable request, i.e. BulkIndexRequest, BulkUpdateRequest, and
// BulkDeleteRequest. | [
"estimateSizeInBytes",
"returns",
"the",
"estimates",
"size",
"of",
"the",
"given",
"bulkable",
"request",
"i",
".",
"e",
".",
"BulkIndexRequest",
"BulkUpdateRequest",
"and",
"BulkDeleteRequest",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk.go#L157-L165 | train |
olivere/elastic | bulk.go | Do | func (s *BulkService) Do(ctx context.Context) (*BulkResponse, error) {
// No actions?
if s.NumberOfActions() == 0 {
return nil, errors.New("elastic: No bulk actions to commit")
}
// Get body
body, err := s.bodyAsString()
if err != nil {
return nil, err
}
// Build url
path := "/"
if len(s.index) > 0 {
index, err := uritemplates.Expand("{index}", map[string]string{
"index": s.index,
})
if err != nil {
return nil, err
}
path += index + "/"
}
if len(s.typ) > 0 {
typ, err := uritemplates.Expand("{type}", map[string]string{
"type": s.typ,
})
if err != nil {
return nil, err
}
path += typ + "/"
}
path += "_bulk"
// Parameters
params := make(url.Values)
if s.pretty {
params.Set("pretty", fmt.Sprintf("%v", s.pretty))
}
if s.pipeline != "" {
params.Set("pipeline", s.pipeline)
}
if s.refresh != "" {
params.Set("refresh", s.refresh)
}
if s.routing != "" {
params.Set("routing", s.routing)
}
if s.timeout != "" {
params.Set("timeout", s.timeout)
}
if s.waitForActiveShards != "" {
params.Set("wait_for_active_shards", s.waitForActiveShards)
}
// Get response
res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
Method: "POST",
Path: path,
Params: params,
Body: body,
ContentType: "application/x-ndjson",
Retrier: s.retrier,
})
if err != nil {
return nil, err
}
// Return results
ret := new(BulkResponse)
if err := s.client.decoder.Decode(res.Body, ret); err != nil {
return nil, err
}
// Reset so the request can be reused
s.Reset()
return ret, nil
} | go | func (s *BulkService) Do(ctx context.Context) (*BulkResponse, error) {
// No actions?
if s.NumberOfActions() == 0 {
return nil, errors.New("elastic: No bulk actions to commit")
}
// Get body
body, err := s.bodyAsString()
if err != nil {
return nil, err
}
// Build url
path := "/"
if len(s.index) > 0 {
index, err := uritemplates.Expand("{index}", map[string]string{
"index": s.index,
})
if err != nil {
return nil, err
}
path += index + "/"
}
if len(s.typ) > 0 {
typ, err := uritemplates.Expand("{type}", map[string]string{
"type": s.typ,
})
if err != nil {
return nil, err
}
path += typ + "/"
}
path += "_bulk"
// Parameters
params := make(url.Values)
if s.pretty {
params.Set("pretty", fmt.Sprintf("%v", s.pretty))
}
if s.pipeline != "" {
params.Set("pipeline", s.pipeline)
}
if s.refresh != "" {
params.Set("refresh", s.refresh)
}
if s.routing != "" {
params.Set("routing", s.routing)
}
if s.timeout != "" {
params.Set("timeout", s.timeout)
}
if s.waitForActiveShards != "" {
params.Set("wait_for_active_shards", s.waitForActiveShards)
}
// Get response
res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
Method: "POST",
Path: path,
Params: params,
Body: body,
ContentType: "application/x-ndjson",
Retrier: s.retrier,
})
if err != nil {
return nil, err
}
// Return results
ret := new(BulkResponse)
if err := s.client.decoder.Decode(res.Body, ret); err != nil {
return nil, err
}
// Reset so the request can be reused
s.Reset()
return ret, nil
} | [
"func",
"(",
"s",
"*",
"BulkService",
")",
"Do",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"BulkResponse",
",",
"error",
")",
"{",
"// No actions?",
"if",
"s",
".",
"NumberOfActions",
"(",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Get body",
"body",
",",
"err",
":=",
"s",
".",
"bodyAsString",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Build url",
"path",
":=",
"\"",
"\"",
"\n",
"if",
"len",
"(",
"s",
".",
"index",
")",
">",
"0",
"{",
"index",
",",
"err",
":=",
"uritemplates",
".",
"Expand",
"(",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"s",
".",
"index",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"path",
"+=",
"index",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"len",
"(",
"s",
".",
"typ",
")",
">",
"0",
"{",
"typ",
",",
"err",
":=",
"uritemplates",
".",
"Expand",
"(",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"s",
".",
"typ",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"path",
"+=",
"typ",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"path",
"+=",
"\"",
"\"",
"\n\n",
"// Parameters",
"params",
":=",
"make",
"(",
"url",
".",
"Values",
")",
"\n",
"if",
"s",
".",
"pretty",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"pretty",
")",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"pipeline",
"!=",
"\"",
"\"",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"s",
".",
"pipeline",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"refresh",
"!=",
"\"",
"\"",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"s",
".",
"refresh",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"routing",
"!=",
"\"",
"\"",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"s",
".",
"routing",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"timeout",
"!=",
"\"",
"\"",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"s",
".",
"timeout",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"waitForActiveShards",
"!=",
"\"",
"\"",
"{",
"params",
".",
"Set",
"(",
"\"",
"\"",
",",
"s",
".",
"waitForActiveShards",
")",
"\n",
"}",
"\n\n",
"// Get response",
"res",
",",
"err",
":=",
"s",
".",
"client",
".",
"PerformRequest",
"(",
"ctx",
",",
"PerformRequestOptions",
"{",
"Method",
":",
"\"",
"\"",
",",
"Path",
":",
"path",
",",
"Params",
":",
"params",
",",
"Body",
":",
"body",
",",
"ContentType",
":",
"\"",
"\"",
",",
"Retrier",
":",
"s",
".",
"retrier",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Return results",
"ret",
":=",
"new",
"(",
"BulkResponse",
")",
"\n",
"if",
"err",
":=",
"s",
".",
"client",
".",
"decoder",
".",
"Decode",
"(",
"res",
".",
"Body",
",",
"ret",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Reset so the request can be reused",
"s",
".",
"Reset",
"(",
")",
"\n\n",
"return",
"ret",
",",
"nil",
"\n",
"}"
] | // Do sends the batched requests to Elasticsearch. Note that, when successful,
// you can reuse the BulkService for the next batch as the list of bulk
// requests is cleared on success. | [
"Do",
"sends",
"the",
"batched",
"requests",
"to",
"Elasticsearch",
".",
"Note",
"that",
"when",
"successful",
"you",
"can",
"reuse",
"the",
"BulkService",
"for",
"the",
"next",
"batch",
"as",
"the",
"list",
"of",
"bulk",
"requests",
"is",
"cleared",
"on",
"success",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/bulk.go#L194-L272 | train |
olivere/elastic | plugins.go | HasPlugin | func (c *Client) HasPlugin(name string) (bool, error) {
plugins, err := c.Plugins()
if err != nil {
return false, nil
}
for _, plugin := range plugins {
if plugin == name {
return true, nil
}
}
return false, nil
} | go | func (c *Client) HasPlugin(name string) (bool, error) {
plugins, err := c.Plugins()
if err != nil {
return false, nil
}
for _, plugin := range plugins {
if plugin == name {
return true, nil
}
}
return false, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"HasPlugin",
"(",
"name",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"plugins",
",",
"err",
":=",
"c",
".",
"Plugins",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"nil",
"\n",
"}",
"\n",
"for",
"_",
",",
"plugin",
":=",
"range",
"plugins",
"{",
"if",
"plugin",
"==",
"name",
"{",
"return",
"true",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
",",
"nil",
"\n",
"}"
] | // HasPlugin indicates whether the cluster has the named plugin. | [
"HasPlugin",
"indicates",
"whether",
"the",
"cluster",
"has",
"the",
"named",
"plugin",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/plugins.go#L10-L21 | train |
olivere/elastic | plugins.go | Plugins | func (c *Client) Plugins() ([]string, error) {
stats, err := c.ClusterStats().Do(context.Background())
if err != nil {
return nil, err
}
if stats == nil {
return nil, err
}
if stats.Nodes == nil {
return nil, err
}
var plugins []string
for _, plugin := range stats.Nodes.Plugins {
plugins = append(plugins, plugin.Name)
}
return plugins, nil
} | go | func (c *Client) Plugins() ([]string, error) {
stats, err := c.ClusterStats().Do(context.Background())
if err != nil {
return nil, err
}
if stats == nil {
return nil, err
}
if stats.Nodes == nil {
return nil, err
}
var plugins []string
for _, plugin := range stats.Nodes.Plugins {
plugins = append(plugins, plugin.Name)
}
return plugins, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Plugins",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"stats",
",",
"err",
":=",
"c",
".",
"ClusterStats",
"(",
")",
".",
"Do",
"(",
"context",
".",
"Background",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"stats",
"==",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"stats",
".",
"Nodes",
"==",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"var",
"plugins",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"plugin",
":=",
"range",
"stats",
".",
"Nodes",
".",
"Plugins",
"{",
"plugins",
"=",
"append",
"(",
"plugins",
",",
"plugin",
".",
"Name",
")",
"\n",
"}",
"\n",
"return",
"plugins",
",",
"nil",
"\n",
"}"
] | // Plugins returns the list of all registered plugins. | [
"Plugins",
"returns",
"the",
"list",
"of",
"all",
"registered",
"plugins",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/plugins.go#L24-L40 | train |
olivere/elastic | cat_allocation.go | NodeID | func (s *CatAllocationService) NodeID(nodes ...string) *CatAllocationService {
s.nodes = nodes
return s
} | go | func (s *CatAllocationService) NodeID(nodes ...string) *CatAllocationService {
s.nodes = nodes
return s
} | [
"func",
"(",
"s",
"*",
"CatAllocationService",
")",
"NodeID",
"(",
"nodes",
"...",
"string",
")",
"*",
"CatAllocationService",
"{",
"s",
".",
"nodes",
"=",
"nodes",
"\n",
"return",
"s",
"\n",
"}"
] | // NodeID specifies one or more node IDs to for information should be returned. | [
"NodeID",
"specifies",
"one",
"or",
"more",
"node",
"IDs",
"to",
"for",
"information",
"should",
"be",
"returned",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/cat_allocation.go#L40-L43 | train |
olivere/elastic | indices_put_settings.go | NewIndicesPutSettingsService | func NewIndicesPutSettingsService(client *Client) *IndicesPutSettingsService {
return &IndicesPutSettingsService{
client: client,
index: make([]string, 0),
}
} | go | func NewIndicesPutSettingsService(client *Client) *IndicesPutSettingsService {
return &IndicesPutSettingsService{
client: client,
index: make([]string, 0),
}
} | [
"func",
"NewIndicesPutSettingsService",
"(",
"client",
"*",
"Client",
")",
"*",
"IndicesPutSettingsService",
"{",
"return",
"&",
"IndicesPutSettingsService",
"{",
"client",
":",
"client",
",",
"index",
":",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
",",
"}",
"\n",
"}"
] | // NewIndicesPutSettingsService creates a new IndicesPutSettingsService. | [
"NewIndicesPutSettingsService",
"creates",
"a",
"new",
"IndicesPutSettingsService",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_put_settings.go#L35-L40 | train |
olivere/elastic | indices_put_settings.go | ExpandWildcards | func (s *IndicesPutSettingsService) ExpandWildcards(expandWildcards string) *IndicesPutSettingsService {
s.expandWildcards = expandWildcards
return s
} | go | func (s *IndicesPutSettingsService) ExpandWildcards(expandWildcards string) *IndicesPutSettingsService {
s.expandWildcards = expandWildcards
return s
} | [
"func",
"(",
"s",
"*",
"IndicesPutSettingsService",
")",
"ExpandWildcards",
"(",
"expandWildcards",
"string",
")",
"*",
"IndicesPutSettingsService",
"{",
"s",
".",
"expandWildcards",
"=",
"expandWildcards",
"\n",
"return",
"s",
"\n",
"}"
] | // ExpandWildcards specifies whether to expand wildcard expression to
// concrete indices that are open, closed or both. | [
"ExpandWildcards",
"specifies",
"whether",
"to",
"expand",
"wildcard",
"expression",
"to",
"concrete",
"indices",
"that",
"are",
"open",
"closed",
"or",
"both",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_put_settings.go#L59-L62 | train |
olivere/elastic | indices_put_settings.go | MasterTimeout | func (s *IndicesPutSettingsService) MasterTimeout(masterTimeout string) *IndicesPutSettingsService {
s.masterTimeout = masterTimeout
return s
} | go | func (s *IndicesPutSettingsService) MasterTimeout(masterTimeout string) *IndicesPutSettingsService {
s.masterTimeout = masterTimeout
return s
} | [
"func",
"(",
"s",
"*",
"IndicesPutSettingsService",
")",
"MasterTimeout",
"(",
"masterTimeout",
"string",
")",
"*",
"IndicesPutSettingsService",
"{",
"s",
".",
"masterTimeout",
"=",
"masterTimeout",
"\n",
"return",
"s",
"\n",
"}"
] | // MasterTimeout is the timeout for connection to master. | [
"MasterTimeout",
"is",
"the",
"timeout",
"for",
"connection",
"to",
"master",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_put_settings.go#L78-L81 | train |
olivere/elastic | uritemplates/uritemplates.go | Parse | func Parse(rawtemplate string) (template *UriTemplate, err error) {
template = new(UriTemplate)
template.raw = rawtemplate
split := strings.Split(rawtemplate, "{")
template.parts = make([]templatePart, len(split)*2-1)
for i, s := range split {
if i == 0 {
if strings.Contains(s, "}") {
err = errors.New("unexpected }")
break
}
template.parts[i].raw = s
} else {
subsplit := strings.Split(s, "}")
if len(subsplit) != 2 {
err = errors.New("malformed template")
break
}
expression := subsplit[0]
template.parts[i*2-1], err = parseExpression(expression)
if err != nil {
break
}
template.parts[i*2].raw = subsplit[1]
}
}
if err != nil {
template = nil
}
return template, err
} | go | func Parse(rawtemplate string) (template *UriTemplate, err error) {
template = new(UriTemplate)
template.raw = rawtemplate
split := strings.Split(rawtemplate, "{")
template.parts = make([]templatePart, len(split)*2-1)
for i, s := range split {
if i == 0 {
if strings.Contains(s, "}") {
err = errors.New("unexpected }")
break
}
template.parts[i].raw = s
} else {
subsplit := strings.Split(s, "}")
if len(subsplit) != 2 {
err = errors.New("malformed template")
break
}
expression := subsplit[0]
template.parts[i*2-1], err = parseExpression(expression)
if err != nil {
break
}
template.parts[i*2].raw = subsplit[1]
}
}
if err != nil {
template = nil
}
return template, err
} | [
"func",
"Parse",
"(",
"rawtemplate",
"string",
")",
"(",
"template",
"*",
"UriTemplate",
",",
"err",
"error",
")",
"{",
"template",
"=",
"new",
"(",
"UriTemplate",
")",
"\n",
"template",
".",
"raw",
"=",
"rawtemplate",
"\n",
"split",
":=",
"strings",
".",
"Split",
"(",
"rawtemplate",
",",
"\"",
"\"",
")",
"\n",
"template",
".",
"parts",
"=",
"make",
"(",
"[",
"]",
"templatePart",
",",
"len",
"(",
"split",
")",
"*",
"2",
"-",
"1",
")",
"\n",
"for",
"i",
",",
"s",
":=",
"range",
"split",
"{",
"if",
"i",
"==",
"0",
"{",
"if",
"strings",
".",
"Contains",
"(",
"s",
",",
"\"",
"\"",
")",
"{",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"break",
"\n",
"}",
"\n",
"template",
".",
"parts",
"[",
"i",
"]",
".",
"raw",
"=",
"s",
"\n",
"}",
"else",
"{",
"subsplit",
":=",
"strings",
".",
"Split",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"subsplit",
")",
"!=",
"2",
"{",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"break",
"\n",
"}",
"\n",
"expression",
":=",
"subsplit",
"[",
"0",
"]",
"\n",
"template",
".",
"parts",
"[",
"i",
"*",
"2",
"-",
"1",
"]",
",",
"err",
"=",
"parseExpression",
"(",
"expression",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n",
"template",
".",
"parts",
"[",
"i",
"*",
"2",
"]",
".",
"raw",
"=",
"subsplit",
"[",
"1",
"]",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"template",
"=",
"nil",
"\n",
"}",
"\n",
"return",
"template",
",",
"err",
"\n",
"}"
] | // Parse parses a URI template string into a UriTemplate object. | [
"Parse",
"parses",
"a",
"URI",
"template",
"string",
"into",
"a",
"UriTemplate",
"object",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/uritemplates/uritemplates.go#L64-L94 | train |
olivere/elastic | uritemplates/uritemplates.go | Expand | func (self *UriTemplate) Expand(value interface{}) (string, error) {
values, ismap := value.(map[string]interface{})
if !ismap {
if m, ismap := struct2map(value); !ismap {
return "", errors.New("expected map[string]interface{}, struct, or pointer to struct.")
} else {
return self.Expand(m)
}
}
var buf bytes.Buffer
for _, p := range self.parts {
err := p.expand(&buf, values)
if err != nil {
return "", err
}
}
return buf.String(), nil
} | go | func (self *UriTemplate) Expand(value interface{}) (string, error) {
values, ismap := value.(map[string]interface{})
if !ismap {
if m, ismap := struct2map(value); !ismap {
return "", errors.New("expected map[string]interface{}, struct, or pointer to struct.")
} else {
return self.Expand(m)
}
}
var buf bytes.Buffer
for _, p := range self.parts {
err := p.expand(&buf, values)
if err != nil {
return "", err
}
}
return buf.String(), nil
} | [
"func",
"(",
"self",
"*",
"UriTemplate",
")",
"Expand",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"values",
",",
"ismap",
":=",
"value",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"if",
"!",
"ismap",
"{",
"if",
"m",
",",
"ismap",
":=",
"struct2map",
"(",
"value",
")",
";",
"!",
"ismap",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"return",
"self",
".",
"Expand",
"(",
"m",
")",
"\n",
"}",
"\n",
"}",
"\n",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"self",
".",
"parts",
"{",
"err",
":=",
"p",
".",
"expand",
"(",
"&",
"buf",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"buf",
".",
"String",
"(",
")",
",",
"nil",
"\n",
"}"
] | // Expand expands a URI template with a set of values to produce a string. | [
"Expand",
"expands",
"a",
"URI",
"template",
"with",
"a",
"set",
"of",
"values",
"to",
"produce",
"a",
"string",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/uritemplates/uritemplates.go#L188-L205 | train |
olivere/elastic | delete_by_query.go | Index | func (s *DeleteByQueryService) Index(index ...string) *DeleteByQueryService {
s.index = append(s.index, index...)
return s
} | go | func (s *DeleteByQueryService) Index(index ...string) *DeleteByQueryService {
s.index = append(s.index, index...)
return s
} | [
"func",
"(",
"s",
"*",
"DeleteByQueryService",
")",
"Index",
"(",
"index",
"...",
"string",
")",
"*",
"DeleteByQueryService",
"{",
"s",
".",
"index",
"=",
"append",
"(",
"s",
".",
"index",
",",
"index",
"...",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // Index sets the indices on which to perform the delete operation. | [
"Index",
"sets",
"the",
"indices",
"on",
"which",
"to",
"perform",
"the",
"delete",
"operation",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/delete_by_query.go#L80-L83 | train |
olivere/elastic | delete_by_query.go | Analyzer | func (s *DeleteByQueryService) Analyzer(analyzer string) *DeleteByQueryService {
s.analyzer = analyzer
return s
} | go | func (s *DeleteByQueryService) Analyzer(analyzer string) *DeleteByQueryService {
s.analyzer = analyzer
return s
} | [
"func",
"(",
"s",
"*",
"DeleteByQueryService",
")",
"Analyzer",
"(",
"analyzer",
"string",
")",
"*",
"DeleteByQueryService",
"{",
"s",
".",
"analyzer",
"=",
"analyzer",
"\n",
"return",
"s",
"\n",
"}"
] | // Analyzer to use for the query string. | [
"Analyzer",
"to",
"use",
"for",
"the",
"query",
"string",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/delete_by_query.go#L114-L117 | train |
olivere/elastic | delete_by_query.go | DF | func (s *DeleteByQueryService) DF(defaultField string) *DeleteByQueryService {
s.df = defaultField
return s
} | go | func (s *DeleteByQueryService) DF(defaultField string) *DeleteByQueryService {
s.df = defaultField
return s
} | [
"func",
"(",
"s",
"*",
"DeleteByQueryService",
")",
"DF",
"(",
"defaultField",
"string",
")",
"*",
"DeleteByQueryService",
"{",
"s",
".",
"df",
"=",
"defaultField",
"\n",
"return",
"s",
"\n",
"}"
] | // DF is the field to use as default where no field prefix is given in the query string. | [
"DF",
"is",
"the",
"field",
"to",
"use",
"as",
"default",
"where",
"no",
"field",
"prefix",
"is",
"given",
"in",
"the",
"query",
"string",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/delete_by_query.go#L162-L165 | train |
olivere/elastic | delete_by_query.go | DefaultField | func (s *DeleteByQueryService) DefaultField(defaultField string) *DeleteByQueryService {
s.df = defaultField
return s
} | go | func (s *DeleteByQueryService) DefaultField(defaultField string) *DeleteByQueryService {
s.df = defaultField
return s
} | [
"func",
"(",
"s",
"*",
"DeleteByQueryService",
")",
"DefaultField",
"(",
"defaultField",
"string",
")",
"*",
"DeleteByQueryService",
"{",
"s",
".",
"df",
"=",
"defaultField",
"\n",
"return",
"s",
"\n",
"}"
] | // DefaultField is the field to use as default where no field prefix is given in the query string.
// It is an alias to the DF func. | [
"DefaultField",
"is",
"the",
"field",
"to",
"use",
"as",
"default",
"where",
"no",
"field",
"prefix",
"is",
"given",
"in",
"the",
"query",
"string",
".",
"It",
"is",
"an",
"alias",
"to",
"the",
"DF",
"func",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/delete_by_query.go#L169-L172 | train |
olivere/elastic | delete_by_query.go | ExpandWildcards | func (s *DeleteByQueryService) ExpandWildcards(expand string) *DeleteByQueryService {
s.expandWildcards = expand
return s
} | go | func (s *DeleteByQueryService) ExpandWildcards(expand string) *DeleteByQueryService {
s.expandWildcards = expand
return s
} | [
"func",
"(",
"s",
"*",
"DeleteByQueryService",
")",
"ExpandWildcards",
"(",
"expand",
"string",
")",
"*",
"DeleteByQueryService",
"{",
"s",
".",
"expandWildcards",
"=",
"expand",
"\n",
"return",
"s",
"\n",
"}"
] | // ExpandWildcards indicates whether to expand wildcard expression to
// concrete indices that are open, closed or both. It can be "open" or "closed". | [
"ExpandWildcards",
"indicates",
"whether",
"to",
"expand",
"wildcard",
"expression",
"to",
"concrete",
"indices",
"that",
"are",
"open",
"closed",
"or",
"both",
".",
"It",
"can",
"be",
"open",
"or",
"closed",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/delete_by_query.go#L182-L185 | train |
olivere/elastic | delete_by_query.go | Q | func (s *DeleteByQueryService) Q(query string) *DeleteByQueryService {
s.q = query
return s
} | go | func (s *DeleteByQueryService) Q(query string) *DeleteByQueryService {
s.q = query
return s
} | [
"func",
"(",
"s",
"*",
"DeleteByQueryService",
")",
"Q",
"(",
"query",
"string",
")",
"*",
"DeleteByQueryService",
"{",
"s",
".",
"q",
"=",
"query",
"\n",
"return",
"s",
"\n",
"}"
] | // Q specifies the query in Lucene query string syntax. You can also use
// Query to programmatically specify the query. | [
"Q",
"specifies",
"the",
"query",
"in",
"Lucene",
"query",
"string",
"syntax",
".",
"You",
"can",
"also",
"use",
"Query",
"to",
"programmatically",
"specify",
"the",
"query",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/delete_by_query.go#L229-L232 | train |
olivere/elastic | delete_by_query.go | QueryString | func (s *DeleteByQueryService) QueryString(query string) *DeleteByQueryService {
s.q = query
return s
} | go | func (s *DeleteByQueryService) QueryString(query string) *DeleteByQueryService {
s.q = query
return s
} | [
"func",
"(",
"s",
"*",
"DeleteByQueryService",
")",
"QueryString",
"(",
"query",
"string",
")",
"*",
"DeleteByQueryService",
"{",
"s",
".",
"q",
"=",
"query",
"\n",
"return",
"s",
"\n",
"}"
] | // QueryString is an alias to Q. Notice that you can also use Query to
// programmatically set the query. | [
"QueryString",
"is",
"an",
"alias",
"to",
"Q",
".",
"Notice",
"that",
"you",
"can",
"also",
"use",
"Query",
"to",
"programmatically",
"set",
"the",
"query",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/delete_by_query.go#L236-L239 | train |
olivere/elastic | delete_by_query.go | Query | func (s *DeleteByQueryService) Query(query Query) *DeleteByQueryService {
s.query = query
return s
} | go | func (s *DeleteByQueryService) Query(query Query) *DeleteByQueryService {
s.query = query
return s
} | [
"func",
"(",
"s",
"*",
"DeleteByQueryService",
")",
"Query",
"(",
"query",
"Query",
")",
"*",
"DeleteByQueryService",
"{",
"s",
".",
"query",
"=",
"query",
"\n",
"return",
"s",
"\n",
"}"
] | // Query sets the query programmatically. | [
"Query",
"sets",
"the",
"query",
"programmatically",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/delete_by_query.go#L242-L245 | train |
olivere/elastic | delete_by_query.go | Pretty | func (s *DeleteByQueryService) Pretty(pretty bool) *DeleteByQueryService {
s.pretty = pretty
return s
} | go | func (s *DeleteByQueryService) Pretty(pretty bool) *DeleteByQueryService {
s.pretty = pretty
return s
} | [
"func",
"(",
"s",
"*",
"DeleteByQueryService",
")",
"Pretty",
"(",
"pretty",
"bool",
")",
"*",
"DeleteByQueryService",
"{",
"s",
".",
"pretty",
"=",
"pretty",
"\n",
"return",
"s",
"\n",
"}"
] | // Pretty indents the JSON output from Elasticsearch. | [
"Pretty",
"indents",
"the",
"JSON",
"output",
"from",
"Elasticsearch",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/delete_by_query.go#L421-L424 | train |
olivere/elastic | delete_by_query.go | Body | func (s *DeleteByQueryService) Body(body string) *DeleteByQueryService {
s.body = body
return s
} | go | func (s *DeleteByQueryService) Body(body string) *DeleteByQueryService {
s.body = body
return s
} | [
"func",
"(",
"s",
"*",
"DeleteByQueryService",
")",
"Body",
"(",
"body",
"string",
")",
"*",
"DeleteByQueryService",
"{",
"s",
".",
"body",
"=",
"body",
"\n",
"return",
"s",
"\n",
"}"
] | // Body specifies the body of the request. It overrides data being specified via SearchService. | [
"Body",
"specifies",
"the",
"body",
"of",
"the",
"request",
".",
"It",
"overrides",
"data",
"being",
"specified",
"via",
"SearchService",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/delete_by_query.go#L427-L430 | train |
olivere/elastic | delete_by_query.go | DoAsync | func (s *DeleteByQueryService) DoAsync(ctx context.Context) (*StartTaskResult, error) {
// Check pre-conditions
if err := s.Validate(); err != nil {
return nil, err
}
// DoAsync only makes sense with WaitForCompletion set to true
if s.waitForCompletion != nil && *s.waitForCompletion {
return nil, fmt.Errorf("cannot start a task with WaitForCompletion set to true")
}
f := false
s.waitForCompletion = &f
// Get URL for request
path, params, err := s.buildURL()
if err != nil {
return nil, err
}
// Set body if there is a query set
var body interface{}
if s.body != nil {
body = s.body
} else if s.query != nil {
src, err := s.query.Source()
if err != nil {
return nil, err
}
body = map[string]interface{}{
"query": src,
}
}
// Get HTTP response
res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
Method: "POST",
Path: path,
Params: params,
Body: body,
})
if err != nil {
return nil, err
}
// Return operation response
ret := new(StartTaskResult)
if err := s.client.decoder.Decode(res.Body, ret); err != nil {
return nil, err
}
return ret, nil
} | go | func (s *DeleteByQueryService) DoAsync(ctx context.Context) (*StartTaskResult, error) {
// Check pre-conditions
if err := s.Validate(); err != nil {
return nil, err
}
// DoAsync only makes sense with WaitForCompletion set to true
if s.waitForCompletion != nil && *s.waitForCompletion {
return nil, fmt.Errorf("cannot start a task with WaitForCompletion set to true")
}
f := false
s.waitForCompletion = &f
// Get URL for request
path, params, err := s.buildURL()
if err != nil {
return nil, err
}
// Set body if there is a query set
var body interface{}
if s.body != nil {
body = s.body
} else if s.query != nil {
src, err := s.query.Source()
if err != nil {
return nil, err
}
body = map[string]interface{}{
"query": src,
}
}
// Get HTTP response
res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
Method: "POST",
Path: path,
Params: params,
Body: body,
})
if err != nil {
return nil, err
}
// Return operation response
ret := new(StartTaskResult)
if err := s.client.decoder.Decode(res.Body, ret); err != nil {
return nil, err
}
return ret, nil
} | [
"func",
"(",
"s",
"*",
"DeleteByQueryService",
")",
"DoAsync",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"StartTaskResult",
",",
"error",
")",
"{",
"// Check pre-conditions",
"if",
"err",
":=",
"s",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// DoAsync only makes sense with WaitForCompletion set to true",
"if",
"s",
".",
"waitForCompletion",
"!=",
"nil",
"&&",
"*",
"s",
".",
"waitForCompletion",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"f",
":=",
"false",
"\n",
"s",
".",
"waitForCompletion",
"=",
"&",
"f",
"\n\n",
"// Get URL for request",
"path",
",",
"params",
",",
"err",
":=",
"s",
".",
"buildURL",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Set body if there is a query set",
"var",
"body",
"interface",
"{",
"}",
"\n",
"if",
"s",
".",
"body",
"!=",
"nil",
"{",
"body",
"=",
"s",
".",
"body",
"\n",
"}",
"else",
"if",
"s",
".",
"query",
"!=",
"nil",
"{",
"src",
",",
"err",
":=",
"s",
".",
"query",
".",
"Source",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"body",
"=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"src",
",",
"}",
"\n",
"}",
"\n\n",
"// Get HTTP response",
"res",
",",
"err",
":=",
"s",
".",
"client",
".",
"PerformRequest",
"(",
"ctx",
",",
"PerformRequestOptions",
"{",
"Method",
":",
"\"",
"\"",
",",
"Path",
":",
"path",
",",
"Params",
":",
"params",
",",
"Body",
":",
"body",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Return operation response",
"ret",
":=",
"new",
"(",
"StartTaskResult",
")",
"\n",
"if",
"err",
":=",
"s",
".",
"client",
".",
"decoder",
".",
"Decode",
"(",
"res",
".",
"Body",
",",
"ret",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"ret",
",",
"nil",
"\n",
"}"
] | // DoAsync executes the delete-by-query operation asynchronously by starting a new task.
// Callers need to use the Task Management API to watch the outcome of the reindexing
// operation. | [
"DoAsync",
"executes",
"the",
"delete",
"-",
"by",
"-",
"query",
"operation",
"asynchronously",
"by",
"starting",
"a",
"new",
"task",
".",
"Callers",
"need",
"to",
"use",
"the",
"Task",
"Management",
"API",
"to",
"watch",
"the",
"outcome",
"of",
"the",
"reindexing",
"operation",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/delete_by_query.go#L643-L693 | train |
olivere/elastic | search_queries_fuzzy.go | NewFuzzyQuery | func NewFuzzyQuery(name string, value interface{}) *FuzzyQuery {
q := &FuzzyQuery{
name: name,
value: value,
}
return q
} | go | func NewFuzzyQuery(name string, value interface{}) *FuzzyQuery {
q := &FuzzyQuery{
name: name,
value: value,
}
return q
} | [
"func",
"NewFuzzyQuery",
"(",
"name",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"*",
"FuzzyQuery",
"{",
"q",
":=",
"&",
"FuzzyQuery",
"{",
"name",
":",
"name",
",",
"value",
":",
"value",
",",
"}",
"\n",
"return",
"q",
"\n",
"}"
] | // NewFuzzyQuery creates a new fuzzy query. | [
"NewFuzzyQuery",
"creates",
"a",
"new",
"fuzzy",
"query",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_fuzzy.go#L25-L31 | train |
olivere/elastic | tasks_get_task.go | TaskIdFromNodeAndId | func (s *TasksGetTaskService) TaskIdFromNodeAndId(nodeId string, id int64) *TasksGetTaskService {
s.taskId = fmt.Sprintf("%s:%d", nodeId, id)
return s
} | go | func (s *TasksGetTaskService) TaskIdFromNodeAndId(nodeId string, id int64) *TasksGetTaskService {
s.taskId = fmt.Sprintf("%s:%d", nodeId, id)
return s
} | [
"func",
"(",
"s",
"*",
"TasksGetTaskService",
")",
"TaskIdFromNodeAndId",
"(",
"nodeId",
"string",
",",
"id",
"int64",
")",
"*",
"TasksGetTaskService",
"{",
"s",
".",
"taskId",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"nodeId",
",",
"id",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // TaskIdFromNodeAndId indicates to return the task on the given node with specified id. | [
"TaskIdFromNodeAndId",
"indicates",
"to",
"return",
"the",
"task",
"on",
"the",
"given",
"node",
"with",
"specified",
"id",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/tasks_get_task.go#L38-L41 | train |
olivere/elastic | search.go | NewSearchService | func NewSearchService(client *Client) *SearchService {
builder := &SearchService{
client: client,
searchSource: NewSearchSource(),
}
return builder
} | go | func NewSearchService(client *Client) *SearchService {
builder := &SearchService{
client: client,
searchSource: NewSearchSource(),
}
return builder
} | [
"func",
"NewSearchService",
"(",
"client",
"*",
"Client",
")",
"*",
"SearchService",
"{",
"builder",
":=",
"&",
"SearchService",
"{",
"client",
":",
"client",
",",
"searchSource",
":",
"NewSearchSource",
"(",
")",
",",
"}",
"\n",
"return",
"builder",
"\n",
"}"
] | // NewSearchService creates a new service for searching in Elasticsearch. | [
"NewSearchService",
"creates",
"a",
"new",
"service",
"for",
"searching",
"in",
"Elasticsearch",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search.go#L38-L44 | train |
olivere/elastic | search.go | Profile | func (s *SearchService) Profile(profile bool) *SearchService {
s.searchSource = s.searchSource.Profile(profile)
return s
} | go | func (s *SearchService) Profile(profile bool) *SearchService {
s.searchSource = s.searchSource.Profile(profile)
return s
} | [
"func",
"(",
"s",
"*",
"SearchService",
")",
"Profile",
"(",
"profile",
"bool",
")",
"*",
"SearchService",
"{",
"s",
".",
"searchSource",
"=",
"s",
".",
"searchSource",
".",
"Profile",
"(",
"profile",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // Profile sets the Profile API flag on the search source.
// When enabled, a search executed by this service will return query
// profiling data. | [
"Profile",
"sets",
"the",
"Profile",
"API",
"flag",
"on",
"the",
"search",
"source",
".",
"When",
"enabled",
"a",
"search",
"executed",
"by",
"this",
"service",
"will",
"return",
"query",
"profiling",
"data",
"."
] | 0534a7b1bf47b1ccf57e905491a641709f8a623d | https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search.go#L100-L103 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.