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
indices_rollover.go
Settings
func (s *IndicesRolloverService) Settings(settings map[string]interface{}) *IndicesRolloverService { s.settings = settings return s }
go
func (s *IndicesRolloverService) Settings(settings map[string]interface{}) *IndicesRolloverService { s.settings = settings return s }
[ "func", "(", "s", "*", "IndicesRolloverService", ")", "Settings", "(", "settings", "map", "[", "string", "]", "interface", "{", "}", ")", "*", "IndicesRolloverService", "{", "s", ".", "settings", "=", "settings", "\n", "return", "s", "\n", "}" ]
// Settings adds the index settings.
[ "Settings", "adds", "the", "index", "settings", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_rollover.go#L116-L119
train
olivere/elastic
indices_rollover.go
AddSetting
func (s *IndicesRolloverService) AddSetting(name string, value interface{}) *IndicesRolloverService { s.settings[name] = value return s }
go
func (s *IndicesRolloverService) AddSetting(name string, value interface{}) *IndicesRolloverService { s.settings[name] = value return s }
[ "func", "(", "s", "*", "IndicesRolloverService", ")", "AddSetting", "(", "name", "string", ",", "value", "interface", "{", "}", ")", "*", "IndicesRolloverService", "{", "s", ".", "settings", "[", "name", "]", "=", "value", "\n", "return", "s", "\n", "}" ]
// AddSetting adds an index setting.
[ "AddSetting", "adds", "an", "index", "setting", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_rollover.go#L122-L125
train
olivere/elastic
indices_rollover.go
Mappings
func (s *IndicesRolloverService) Mappings(mappings map[string]interface{}) *IndicesRolloverService { s.mappings = mappings return s }
go
func (s *IndicesRolloverService) Mappings(mappings map[string]interface{}) *IndicesRolloverService { s.mappings = mappings return s }
[ "func", "(", "s", "*", "IndicesRolloverService", ")", "Mappings", "(", "mappings", "map", "[", "string", "]", "interface", "{", "}", ")", "*", "IndicesRolloverService", "{", "s", ".", "mappings", "=", "mappings", "\n", "return", "s", "\n", "}" ]
// Mappings adds the index mappings.
[ "Mappings", "adds", "the", "index", "mappings", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_rollover.go#L128-L131
train
olivere/elastic
indices_rollover.go
AddMapping
func (s *IndicesRolloverService) AddMapping(typ string, mapping interface{}) *IndicesRolloverService { s.mappings[typ] = mapping return s }
go
func (s *IndicesRolloverService) AddMapping(typ string, mapping interface{}) *IndicesRolloverService { s.mappings[typ] = mapping return s }
[ "func", "(", "s", "*", "IndicesRolloverService", ")", "AddMapping", "(", "typ", "string", ",", "mapping", "interface", "{", "}", ")", "*", "IndicesRolloverService", "{", "s", ".", "mappings", "[", "typ", "]", "=", "mapping", "\n", "return", "s", "\n", "}" ]
// AddMapping adds a mapping for the given type.
[ "AddMapping", "adds", "a", "mapping", "for", "the", "given", "type", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_rollover.go#L134-L137
train
olivere/elastic
indices_rollover.go
BodyString
func (s *IndicesRolloverService) BodyString(body string) *IndicesRolloverService { s.bodyString = body return s }
go
func (s *IndicesRolloverService) BodyString(body string) *IndicesRolloverService { s.bodyString = body return s }
[ "func", "(", "s", "*", "IndicesRolloverService", ")", "BodyString", "(", "body", "string", ")", "*", "IndicesRolloverService", "{", "s", ".", "bodyString", "=", "body", "\n", "return", "s", "\n", "}" ]
// BodyString sets the conditions that needs to be met for executing rollover, // specified as a string which is sent as the body of the request.
[ "BodyString", "sets", "the", "conditions", "that", "needs", "to", "be", "met", "for", "executing", "rollover", "specified", "as", "a", "string", "which", "is", "sent", "as", "the", "body", "of", "the", "request", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_rollover.go#L149-L152
train
olivere/elastic
indices_rollover.go
getBody
func (s *IndicesRolloverService) getBody() interface{} { body := make(map[string]interface{}) if len(s.conditions) > 0 { body["conditions"] = s.conditions } if len(s.settings) > 0 { body["settings"] = s.settings } if len(s.mappings) > 0 { body["mappings"] = s.mappings } return body }
go
func (s *IndicesRolloverService) getBody() interface{} { body := make(map[string]interface{}) if len(s.conditions) > 0 { body["conditions"] = s.conditions } if len(s.settings) > 0 { body["settings"] = s.settings } if len(s.mappings) > 0 { body["mappings"] = s.mappings } return body }
[ "func", "(", "s", "*", "IndicesRolloverService", ")", "getBody", "(", ")", "interface", "{", "}", "{", "body", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "if", "len", "(", "s", ".", "conditions", ")", ">", "0", "{", "body", "[", "\"", "\"", "]", "=", "s", ".", "conditions", "\n", "}", "\n", "if", "len", "(", "s", ".", "settings", ")", ">", "0", "{", "body", "[", "\"", "\"", "]", "=", "s", ".", "settings", "\n", "}", "\n", "if", "len", "(", "s", ".", "mappings", ")", ">", "0", "{", "body", "[", "\"", "\"", "]", "=", "s", ".", "mappings", "\n", "}", "\n", "return", "body", "\n", "}" ]
// getBody returns the body of the request, if not explicitly set via // BodyJson or BodyString.
[ "getBody", "returns", "the", "body", "of", "the", "request", "if", "not", "explicitly", "set", "via", "BodyJson", "or", "BodyString", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_rollover.go#L156-L168
train
olivere/elastic
search_aggs_matrix_stats.go
Source
func (a *MatrixStatsAggregation) Source() (interface{}, error) { // Example: // { // "aggs" : { // "matrixstats" : { // "matrix_stats" : { // "fields" : ["poverty", "income"], // "missing": {"income": 50000}, // "mode": "avg", // ... // } // } // } // } // This method returns only the { "matrix_stats" : { ... } } part. source := make(map[string]interface{}) opts := make(map[string]interface{}) source["matrix_stats"] = opts // MatrixStatsAggregationBuilder opts["fields"] = a.fields if a.missing != nil { opts["missing"] = a.missing } if a.format != "" { opts["format"] = a.format } if a.valueType != nil { opts["value_type"] = a.valueType } if a.mode != "" { opts["mode"] = a.mode } // AggregationBuilder (SubAggregations) if len(a.subAggregations) > 0 { aggsMap := make(map[string]interface{}) source["aggregations"] = aggsMap for name, aggregate := range a.subAggregations { src, err := aggregate.Source() if err != nil { return nil, err } aggsMap[name] = src } } // Add Meta data if available if len(a.meta) > 0 { source["meta"] = a.meta } return source, nil }
go
func (a *MatrixStatsAggregation) Source() (interface{}, error) { // Example: // { // "aggs" : { // "matrixstats" : { // "matrix_stats" : { // "fields" : ["poverty", "income"], // "missing": {"income": 50000}, // "mode": "avg", // ... // } // } // } // } // This method returns only the { "matrix_stats" : { ... } } part. source := make(map[string]interface{}) opts := make(map[string]interface{}) source["matrix_stats"] = opts // MatrixStatsAggregationBuilder opts["fields"] = a.fields if a.missing != nil { opts["missing"] = a.missing } if a.format != "" { opts["format"] = a.format } if a.valueType != nil { opts["value_type"] = a.valueType } if a.mode != "" { opts["mode"] = a.mode } // AggregationBuilder (SubAggregations) if len(a.subAggregations) > 0 { aggsMap := make(map[string]interface{}) source["aggregations"] = aggsMap for name, aggregate := range a.subAggregations { src, err := aggregate.Source() if err != nil { return nil, err } aggsMap[name] = src } } // Add Meta data if available if len(a.meta) > 0 { source["meta"] = a.meta } return source, nil }
[ "func", "(", "a", "*", "MatrixStatsAggregation", ")", "Source", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "// Example:", "//\t{", "// \"aggs\" : {", "// \"matrixstats\" : {", "// \"matrix_stats\" : {", "// \"fields\" : [\"poverty\", \"income\"],", "// \"missing\": {\"income\": 50000},", "// \"mode\": \"avg\",", "// ...", "// }", "// }", "// }", "//\t}", "// This method returns only the { \"matrix_stats\" : { ... } } part.", "source", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "opts", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "source", "[", "\"", "\"", "]", "=", "opts", "\n\n", "// MatrixStatsAggregationBuilder", "opts", "[", "\"", "\"", "]", "=", "a", ".", "fields", "\n", "if", "a", ".", "missing", "!=", "nil", "{", "opts", "[", "\"", "\"", "]", "=", "a", ".", "missing", "\n", "}", "\n", "if", "a", ".", "format", "!=", "\"", "\"", "{", "opts", "[", "\"", "\"", "]", "=", "a", ".", "format", "\n", "}", "\n", "if", "a", ".", "valueType", "!=", "nil", "{", "opts", "[", "\"", "\"", "]", "=", "a", ".", "valueType", "\n", "}", "\n", "if", "a", ".", "mode", "!=", "\"", "\"", "{", "opts", "[", "\"", "\"", "]", "=", "a", ".", "mode", "\n", "}", "\n\n", "// AggregationBuilder (SubAggregations)", "if", "len", "(", "a", ".", "subAggregations", ")", ">", "0", "{", "aggsMap", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "source", "[", "\"", "\"", "]", "=", "aggsMap", "\n", "for", "name", ",", "aggregate", ":=", "range", "a", ".", "subAggregations", "{", "src", ",", "err", ":=", "aggregate", ".", "Source", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "aggsMap", "[", "name", "]", "=", "src", "\n", "}", "\n", "}", "\n\n", "// Add Meta data if available", "if", "len", "(", "a", ".", "meta", ")", ">", "0", "{", "source", "[", "\"", "\"", "]", "=", "a", ".", "meta", "\n", "}", "\n\n", "return", "source", ",", "nil", "\n", "}" ]
// Source returns the JSON to serialize into the request, or an error.
[ "Source", "returns", "the", "JSON", "to", "serialize", "into", "the", "request", "or", "an", "error", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_aggs_matrix_stats.go#L72-L126
train
olivere/elastic
xpack_security_delete_role.go
Name
func (s *XPackSecurityDeleteRoleService) Name(name string) *XPackSecurityDeleteRoleService { s.name = name return s }
go
func (s *XPackSecurityDeleteRoleService) Name(name string) *XPackSecurityDeleteRoleService { s.name = name return s }
[ "func", "(", "s", "*", "XPackSecurityDeleteRoleService", ")", "Name", "(", "name", "string", ")", "*", "XPackSecurityDeleteRoleService", "{", "s", ".", "name", "=", "name", "\n", "return", "s", "\n", "}" ]
// Name is name of the role to delete.
[ "Name", "is", "name", "of", "the", "role", "to", "delete", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/xpack_security_delete_role.go#L32-L35
train
olivere/elastic
search_queries_match.go
NewMatchQuery
func NewMatchQuery(name string, text interface{}) *MatchQuery { return &MatchQuery{name: name, text: text} }
go
func NewMatchQuery(name string, text interface{}) *MatchQuery { return &MatchQuery{name: name, text: text} }
[ "func", "NewMatchQuery", "(", "name", "string", ",", "text", "interface", "{", "}", ")", "*", "MatchQuery", "{", "return", "&", "MatchQuery", "{", "name", ":", "name", ",", "text", ":", "text", "}", "\n", "}" ]
// NewMatchQuery creates and initializes a new MatchQuery.
[ "NewMatchQuery", "creates", "and", "initializes", "a", "new", "MatchQuery", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_match.go#L35-L37
train
olivere/elastic
search_queries_match.go
MaxExpansions
func (q *MatchQuery) MaxExpansions(maxExpansions int) *MatchQuery { q.maxExpansions = &maxExpansions return q }
go
func (q *MatchQuery) MaxExpansions(maxExpansions int) *MatchQuery { q.maxExpansions = &maxExpansions return q }
[ "func", "(", "q", "*", "MatchQuery", ")", "MaxExpansions", "(", "maxExpansions", "int", ")", "*", "MatchQuery", "{", "q", ".", "maxExpansions", "=", "&", "maxExpansions", "\n", "return", "q", "\n", "}" ]
// MaxExpansions is used with fuzzy or prefix type queries. It specifies // the number of term expansions to use. It defaults to unbounded so that // its recommended to set it to a reasonable value for faster execution.
[ "MaxExpansions", "is", "used", "with", "fuzzy", "or", "prefix", "type", "queries", ".", "It", "specifies", "the", "number", "of", "term", "expansions", "to", "use", ".", "It", "defaults", "to", "unbounded", "so", "that", "its", "recommended", "to", "set", "it", "to", "a", "reasonable", "value", "for", "faster", "execution", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_match.go#L70-L73
train
olivere/elastic
search_queries_terms.go
NewTermsQuery
func NewTermsQuery(name string, values ...interface{}) *TermsQuery { q := &TermsQuery{ name: name, values: make([]interface{}, 0), } if len(values) > 0 { q.values = append(q.values, values...) } return q }
go
func NewTermsQuery(name string, values ...interface{}) *TermsQuery { q := &TermsQuery{ name: name, values: make([]interface{}, 0), } if len(values) > 0 { q.values = append(q.values, values...) } return q }
[ "func", "NewTermsQuery", "(", "name", "string", ",", "values", "...", "interface", "{", "}", ")", "*", "TermsQuery", "{", "q", ":=", "&", "TermsQuery", "{", "name", ":", "name", ",", "values", ":", "make", "(", "[", "]", "interface", "{", "}", ",", "0", ")", ",", "}", "\n", "if", "len", "(", "values", ")", ">", "0", "{", "q", ".", "values", "=", "append", "(", "q", ".", "values", ",", "values", "...", ")", "\n", "}", "\n", "return", "q", "\n", "}" ]
// NewTermsQuery creates and initializes a new TermsQuery.
[ "NewTermsQuery", "creates", "and", "initializes", "a", "new", "TermsQuery", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_terms.go#L21-L30
train
olivere/elastic
search_queries_terms.go
TermsLookup
func (q *TermsQuery) TermsLookup(lookup *TermsLookup) *TermsQuery { q.termsLookup = lookup return q }
go
func (q *TermsQuery) TermsLookup(lookup *TermsLookup) *TermsQuery { q.termsLookup = lookup return q }
[ "func", "(", "q", "*", "TermsQuery", ")", "TermsLookup", "(", "lookup", "*", "TermsLookup", ")", "*", "TermsQuery", "{", "q", ".", "termsLookup", "=", "lookup", "\n", "return", "q", "\n", "}" ]
// TermsLookup adds terms lookup details to the query.
[ "TermsLookup", "adds", "terms", "lookup", "details", "to", "the", "query", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_terms.go#L33-L36
train
olivere/elastic
geo_point.go
Source
func (pt *GeoPoint) Source() map[string]float64 { return map[string]float64{ "lat": pt.Lat, "lon": pt.Lon, } }
go
func (pt *GeoPoint) Source() map[string]float64 { return map[string]float64{ "lat": pt.Lat, "lon": pt.Lon, } }
[ "func", "(", "pt", "*", "GeoPoint", ")", "Source", "(", ")", "map", "[", "string", "]", "float64", "{", "return", "map", "[", "string", "]", "float64", "{", "\"", "\"", ":", "pt", ".", "Lat", ",", "\"", "\"", ":", "pt", ".", "Lon", ",", "}", "\n", "}" ]
// Source returns the object to be serialized in Elasticsearch DSL.
[ "Source", "returns", "the", "object", "to", "be", "serialized", "in", "Elasticsearch", "DSL", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/geo_point.go#L21-L26
train
olivere/elastic
geo_point.go
GeoPointFromLatLon
func GeoPointFromLatLon(lat, lon float64) *GeoPoint { return &GeoPoint{Lat: lat, Lon: lon} }
go
func GeoPointFromLatLon(lat, lon float64) *GeoPoint { return &GeoPoint{Lat: lat, Lon: lon} }
[ "func", "GeoPointFromLatLon", "(", "lat", ",", "lon", "float64", ")", "*", "GeoPoint", "{", "return", "&", "GeoPoint", "{", "Lat", ":", "lat", ",", "Lon", ":", "lon", "}", "\n", "}" ]
// GeoPointFromLatLon initializes a new GeoPoint by latitude and longitude.
[ "GeoPointFromLatLon", "initializes", "a", "new", "GeoPoint", "by", "latitude", "and", "longitude", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/geo_point.go#L34-L36
train
olivere/elastic
xpack_watcher_execute_watch.go
Id
func (s *XPackWatcherExecuteWatchService) Id(id string) *XPackWatcherExecuteWatchService { s.id = id return s }
go
func (s *XPackWatcherExecuteWatchService) Id(id string) *XPackWatcherExecuteWatchService { s.id = id return s }
[ "func", "(", "s", "*", "XPackWatcherExecuteWatchService", ")", "Id", "(", "id", "string", ")", "*", "XPackWatcherExecuteWatchService", "{", "s", ".", "id", "=", "id", "\n", "return", "s", "\n", "}" ]
// Id of the watch to execute on.
[ "Id", "of", "the", "watch", "to", "execute", "on", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/xpack_watcher_execute_watch.go#L35-L38
train
olivere/elastic
xpack_watcher_execute_watch.go
Debug
func (s *XPackWatcherExecuteWatchService) Debug(debug bool) *XPackWatcherExecuteWatchService { s.debug = &debug return s }
go
func (s *XPackWatcherExecuteWatchService) Debug(debug bool) *XPackWatcherExecuteWatchService { s.debug = &debug return s }
[ "func", "(", "s", "*", "XPackWatcherExecuteWatchService", ")", "Debug", "(", "debug", "bool", ")", "*", "XPackWatcherExecuteWatchService", "{", "s", ".", "debug", "=", "&", "debug", "\n", "return", "s", "\n", "}" ]
// Debug indicates whether the watch should execute in debug mode.
[ "Debug", "indicates", "whether", "the", "watch", "should", "execute", "in", "debug", "mode", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/xpack_watcher_execute_watch.go#L41-L44
train
olivere/elastic
search_queries_common_terms.go
NewCommonTermsQuery
func NewCommonTermsQuery(name string, text interface{}) *CommonTermsQuery { return &CommonTermsQuery{name: name, text: text} }
go
func NewCommonTermsQuery(name string, text interface{}) *CommonTermsQuery { return &CommonTermsQuery{name: name, text: text} }
[ "func", "NewCommonTermsQuery", "(", "name", "string", ",", "text", "interface", "{", "}", ")", "*", "CommonTermsQuery", "{", "return", "&", "CommonTermsQuery", "{", "name", ":", "name", ",", "text", ":", "text", "}", "\n", "}" ]
// NewCommonTermsQuery creates and initializes a new common terms query.
[ "NewCommonTermsQuery", "creates", "and", "initializes", "a", "new", "common", "terms", "query", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_common_terms.go#L29-L31
train
olivere/elastic
get.go
IgnoreErrorsOnGeneratedFields
func (s *GetService) IgnoreErrorsOnGeneratedFields(ignore bool) *GetService { s.ignoreErrorsOnGeneratedFields = &ignore return s }
go
func (s *GetService) IgnoreErrorsOnGeneratedFields(ignore bool) *GetService { s.ignoreErrorsOnGeneratedFields = &ignore return s }
[ "func", "(", "s", "*", "GetService", ")", "IgnoreErrorsOnGeneratedFields", "(", "ignore", "bool", ")", "*", "GetService", "{", "s", ".", "ignoreErrorsOnGeneratedFields", "=", "&", "ignore", "\n", "return", "s", "\n", "}" ]
// IgnoreErrorsOnGeneratedFields indicates whether to ignore fields that // are generated if the transaction log is accessed.
[ "IgnoreErrorsOnGeneratedFields", "indicates", "whether", "to", "ignore", "fields", "that", "are", "generated", "if", "the", "transaction", "log", "is", "accessed", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/get.go#L135-L138
train
olivere/elastic
indices_stats.go
NewIndicesStatsService
func NewIndicesStatsService(client *Client) *IndicesStatsService { return &IndicesStatsService{ client: client, index: make([]string, 0), metric: make([]string, 0), completionFields: make([]string, 0), fielddataFields: make([]string, 0), fields: make([]string, 0), groups: make([]string, 0), types: make([]string, 0), } }
go
func NewIndicesStatsService(client *Client) *IndicesStatsService { return &IndicesStatsService{ client: client, index: make([]string, 0), metric: make([]string, 0), completionFields: make([]string, 0), fielddataFields: make([]string, 0), fields: make([]string, 0), groups: make([]string, 0), types: make([]string, 0), } }
[ "func", "NewIndicesStatsService", "(", "client", "*", "Client", ")", "*", "IndicesStatsService", "{", "return", "&", "IndicesStatsService", "{", "client", ":", "client", ",", "index", ":", "make", "(", "[", "]", "string", ",", "0", ")", ",", "metric", ":", "make", "(", "[", "]", "string", ",", "0", ")", ",", "completionFields", ":", "make", "(", "[", "]", "string", ",", "0", ")", ",", "fielddataFields", ":", "make", "(", "[", "]", "string", ",", "0", ")", ",", "fields", ":", "make", "(", "[", "]", "string", ",", "0", ")", ",", "groups", ":", "make", "(", "[", "]", "string", ",", "0", ")", ",", "types", ":", "make", "(", "[", "]", "string", ",", "0", ")", ",", "}", "\n", "}" ]
// NewIndicesStatsService creates a new IndicesStatsService.
[ "NewIndicesStatsService", "creates", "a", "new", "IndicesStatsService", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_stats.go#L33-L44
train
olivere/elastic
indices_stats.go
Index
func (s *IndicesStatsService) Index(indices ...string) *IndicesStatsService { s.index = append(s.index, indices...) return s }
go
func (s *IndicesStatsService) Index(indices ...string) *IndicesStatsService { s.index = append(s.index, indices...) return s }
[ "func", "(", "s", "*", "IndicesStatsService", ")", "Index", "(", "indices", "...", "string", ")", "*", "IndicesStatsService", "{", "s", ".", "index", "=", "append", "(", "s", ".", "index", ",", "indices", "...", ")", "\n", "return", "s", "\n", "}" ]
// Index is the list of index names; use `_all` or empty string to perform // the operation on all indices.
[ "Index", "is", "the", "list", "of", "index", "names", ";", "use", "_all", "or", "empty", "string", "to", "perform", "the", "operation", "on", "all", "indices", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_stats.go#L56-L59
train
olivere/elastic
indices_stats.go
Type
func (s *IndicesStatsService) Type(types ...string) *IndicesStatsService { s.types = append(s.types, types...) return s }
go
func (s *IndicesStatsService) Type(types ...string) *IndicesStatsService { s.types = append(s.types, types...) return s }
[ "func", "(", "s", "*", "IndicesStatsService", ")", "Type", "(", "types", "...", "string", ")", "*", "IndicesStatsService", "{", "s", ".", "types", "=", "append", "(", "s", ".", "types", ",", "types", "...", ")", "\n", "return", "s", "\n", "}" ]
// Type is a list of document types for the `indexing` index metric.
[ "Type", "is", "a", "list", "of", "document", "types", "for", "the", "indexing", "index", "metric", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_stats.go#L62-L65
train
olivere/elastic
indices_stats.go
Level
func (s *IndicesStatsService) Level(level string) *IndicesStatsService { s.level = level return s }
go
func (s *IndicesStatsService) Level(level string) *IndicesStatsService { s.level = level return s }
[ "func", "(", "s", "*", "IndicesStatsService", ")", "Level", "(", "level", "string", ")", "*", "IndicesStatsService", "{", "s", ".", "level", "=", "level", "\n", "return", "s", "\n", "}" ]
// Level returns stats aggregated at cluster, index or shard level.
[ "Level", "returns", "stats", "aggregated", "at", "cluster", "index", "or", "shard", "level", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_stats.go#L68-L71
train
olivere/elastic
indices_stats.go
Human
func (s *IndicesStatsService) Human(human bool) *IndicesStatsService { s.human = &human return s }
go
func (s *IndicesStatsService) Human(human bool) *IndicesStatsService { s.human = &human return s }
[ "func", "(", "s", "*", "IndicesStatsService", ")", "Human", "(", "human", "bool", ")", "*", "IndicesStatsService", "{", "s", ".", "human", "=", "&", "human", "\n", "return", "s", "\n", "}" ]
// Human indicates whether to return time and byte values in human-readable format..
[ "Human", "indicates", "whether", "to", "return", "time", "and", "byte", "values", "in", "human", "-", "readable", "format", ".." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_stats.go#L100-L103
train
olivere/elastic
search_aggs_bucket_histogram.go
Interval
func (a *HistogramAggregation) Interval(interval float64) *HistogramAggregation { a.interval = interval return a }
go
func (a *HistogramAggregation) Interval(interval float64) *HistogramAggregation { a.interval = interval return a }
[ "func", "(", "a", "*", "HistogramAggregation", ")", "Interval", "(", "interval", "float64", ")", "*", "HistogramAggregation", "{", "a", ".", "interval", "=", "interval", "\n", "return", "a", "\n", "}" ]
// Interval for this builder, must be greater than 0.
[ "Interval", "for", "this", "builder", "must", "be", "greater", "than", "0", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_aggs_bucket_histogram.go#L62-L65
train
olivere/elastic
search_aggs_bucket_histogram.go
Offset
func (a *HistogramAggregation) Offset(offset float64) *HistogramAggregation { a.offset = &offset return a }
go
func (a *HistogramAggregation) Offset(offset float64) *HistogramAggregation { a.offset = &offset return a }
[ "func", "(", "a", "*", "HistogramAggregation", ")", "Offset", "(", "offset", "float64", ")", "*", "HistogramAggregation", "{", "a", ".", "offset", "=", "&", "offset", "\n", "return", "a", "\n", "}" ]
// Offset into the histogram
[ "Offset", "into", "the", "histogram" ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_aggs_bucket_histogram.go#L180-L183
train
olivere/elastic
indices_put_template.go
Cause
func (s *IndicesPutTemplateService) Cause(cause string) *IndicesPutTemplateService { s.cause = cause return s }
go
func (s *IndicesPutTemplateService) Cause(cause string) *IndicesPutTemplateService { s.cause = cause return s }
[ "func", "(", "s", "*", "IndicesPutTemplateService", ")", "Cause", "(", "cause", "string", ")", "*", "IndicesPutTemplateService", "{", "s", ".", "cause", "=", "cause", "\n", "return", "s", "\n", "}" ]
// Cause describes the cause for this index template creation. This is currently // undocumented, but part of the Java source.
[ "Cause", "describes", "the", "cause", "for", "this", "index", "template", "creation", ".", "This", "is", "currently", "undocumented", "but", "part", "of", "the", "Java", "source", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_put_template.go#L47-L50
train
olivere/elastic
indices_put_template.go
Version
func (s *IndicesPutTemplateService) Version(version int) *IndicesPutTemplateService { s.version = &version return s }
go
func (s *IndicesPutTemplateService) Version(version int) *IndicesPutTemplateService { s.version = &version return s }
[ "func", "(", "s", "*", "IndicesPutTemplateService", ")", "Version", "(", "version", "int", ")", "*", "IndicesPutTemplateService", "{", "s", ".", "version", "=", "&", "version", "\n", "return", "s", "\n", "}" ]
// Version sets the version number for this template.
[ "Version", "sets", "the", "version", "number", "for", "this", "template", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_put_template.go#L78-L81
train
olivere/elastic
indices_put_template.go
Create
func (s *IndicesPutTemplateService) Create(create bool) *IndicesPutTemplateService { s.create = &create return s }
go
func (s *IndicesPutTemplateService) Create(create bool) *IndicesPutTemplateService { s.create = &create return s }
[ "func", "(", "s", "*", "IndicesPutTemplateService", ")", "Create", "(", "create", "bool", ")", "*", "IndicesPutTemplateService", "{", "s", ".", "create", "=", "&", "create", "\n", "return", "s", "\n", "}" ]
// Create indicates whether the index template should only be added if // new or can also replace an existing one.
[ "Create", "indicates", "whether", "the", "index", "template", "should", "only", "be", "added", "if", "new", "or", "can", "also", "replace", "an", "existing", "one", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_put_template.go#L85-L88
train
olivere/elastic
search_collapse_builder.go
Field
func (b *CollapseBuilder) Field(field string) *CollapseBuilder { b.field = field return b }
go
func (b *CollapseBuilder) Field(field string) *CollapseBuilder { b.field = field return b }
[ "func", "(", "b", "*", "CollapseBuilder", ")", "Field", "(", "field", "string", ")", "*", "CollapseBuilder", "{", "b", ".", "field", "=", "field", "\n", "return", "b", "\n", "}" ]
// Field to collapse.
[ "Field", "to", "collapse", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_collapse_builder.go#L22-L25
train
olivere/elastic
search_collapse_builder.go
InnerHit
func (b *CollapseBuilder) InnerHit(innerHit *InnerHit) *CollapseBuilder { b.innerHit = innerHit return b }
go
func (b *CollapseBuilder) InnerHit(innerHit *InnerHit) *CollapseBuilder { b.innerHit = innerHit return b }
[ "func", "(", "b", "*", "CollapseBuilder", ")", "InnerHit", "(", "innerHit", "*", "InnerHit", ")", "*", "CollapseBuilder", "{", "b", ".", "innerHit", "=", "innerHit", "\n", "return", "b", "\n", "}" ]
// InnerHit option to expand the collapsed results.
[ "InnerHit", "option", "to", "expand", "the", "collapsed", "results", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_collapse_builder.go#L28-L31
train
olivere/elastic
search_collapse_builder.go
MaxConcurrentGroupRequests
func (b *CollapseBuilder) MaxConcurrentGroupRequests(max int) *CollapseBuilder { b.maxConcurrentGroupRequests = &max return b }
go
func (b *CollapseBuilder) MaxConcurrentGroupRequests(max int) *CollapseBuilder { b.maxConcurrentGroupRequests = &max return b }
[ "func", "(", "b", "*", "CollapseBuilder", ")", "MaxConcurrentGroupRequests", "(", "max", "int", ")", "*", "CollapseBuilder", "{", "b", ".", "maxConcurrentGroupRequests", "=", "&", "max", "\n", "return", "b", "\n", "}" ]
// MaxConcurrentGroupRequests is the maximum number of group requests that are // allowed to be ran concurrently in the inner_hits phase.
[ "MaxConcurrentGroupRequests", "is", "the", "maximum", "number", "of", "group", "requests", "that", "are", "allowed", "to", "be", "ran", "concurrently", "in", "the", "inner_hits", "phase", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_collapse_builder.go#L35-L38
train
olivere/elastic
search_collapse_builder.go
Source
func (b *CollapseBuilder) Source() (interface{}, error) { // { // "field": "user", // "inner_hits": { // "name": "last_tweets", // "size": 5, // "sort": [{ "date": "asc" }] // }, // "max_concurrent_group_searches": 4 // } src := map[string]interface{}{ "field": b.field, } if b.innerHit != nil { hits, err := b.innerHit.Source() if err != nil { return nil, err } src["inner_hits"] = hits } if b.maxConcurrentGroupRequests != nil { src["max_concurrent_group_searches"] = *b.maxConcurrentGroupRequests } return src, nil }
go
func (b *CollapseBuilder) Source() (interface{}, error) { // { // "field": "user", // "inner_hits": { // "name": "last_tweets", // "size": 5, // "sort": [{ "date": "asc" }] // }, // "max_concurrent_group_searches": 4 // } src := map[string]interface{}{ "field": b.field, } if b.innerHit != nil { hits, err := b.innerHit.Source() if err != nil { return nil, err } src["inner_hits"] = hits } if b.maxConcurrentGroupRequests != nil { src["max_concurrent_group_searches"] = *b.maxConcurrentGroupRequests } return src, nil }
[ "func", "(", "b", "*", "CollapseBuilder", ")", "Source", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "// {", "// \"field\": \"user\",", "// \"inner_hits\": {", "// \"name\": \"last_tweets\",", "// \"size\": 5,", "// \"sort\": [{ \"date\": \"asc\" }]", "// },", "// \"max_concurrent_group_searches\": 4", "// }", "src", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "b", ".", "field", ",", "}", "\n\n", "if", "b", ".", "innerHit", "!=", "nil", "{", "hits", ",", "err", ":=", "b", ".", "innerHit", ".", "Source", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "src", "[", "\"", "\"", "]", "=", "hits", "\n", "}", "\n\n", "if", "b", ".", "maxConcurrentGroupRequests", "!=", "nil", "{", "src", "[", "\"", "\"", "]", "=", "*", "b", ".", "maxConcurrentGroupRequests", "\n", "}", "\n\n", "return", "src", ",", "nil", "\n", "}" ]
// Source generates the JSON serializable fragment for the CollapseBuilder.
[ "Source", "generates", "the", "JSON", "serializable", "fragment", "for", "the", "CollapseBuilder", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_collapse_builder.go#L41-L68
train
olivere/elastic
indices_close.go
Index
func (s *IndicesCloseService) Index(index string) *IndicesCloseService { s.index = index return s }
go
func (s *IndicesCloseService) Index(index string) *IndicesCloseService { s.index = index return s }
[ "func", "(", "s", "*", "IndicesCloseService", ")", "Index", "(", "index", "string", ")", "*", "IndicesCloseService", "{", "s", ".", "index", "=", "index", "\n", "return", "s", "\n", "}" ]
// Index is the name of the index to close.
[ "Index", "is", "the", "name", "of", "the", "index", "to", "close", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_close.go#L36-L39
train
olivere/elastic
search_queries_regexp.go
Source
func (q *RegexpQuery) Source() (interface{}, error) { source := make(map[string]interface{}) query := make(map[string]interface{}) source["regexp"] = query x := make(map[string]interface{}) x["value"] = q.regexp if q.flags != "" { x["flags"] = q.flags } if q.maxDeterminizedStates != nil { x["max_determinized_states"] = *q.maxDeterminizedStates } if q.boost != nil { x["boost"] = *q.boost } if q.rewrite != "" { x["rewrite"] = q.rewrite } if q.queryName != "" { x["name"] = q.queryName } query[q.name] = x return source, nil }
go
func (q *RegexpQuery) Source() (interface{}, error) { source := make(map[string]interface{}) query := make(map[string]interface{}) source["regexp"] = query x := make(map[string]interface{}) x["value"] = q.regexp if q.flags != "" { x["flags"] = q.flags } if q.maxDeterminizedStates != nil { x["max_determinized_states"] = *q.maxDeterminizedStates } if q.boost != nil { x["boost"] = *q.boost } if q.rewrite != "" { x["rewrite"] = q.rewrite } if q.queryName != "" { x["name"] = q.queryName } query[q.name] = x return source, nil }
[ "func", "(", "q", "*", "RegexpQuery", ")", "Source", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "source", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "query", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "source", "[", "\"", "\"", "]", "=", "query", "\n\n", "x", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "x", "[", "\"", "\"", "]", "=", "q", ".", "regexp", "\n", "if", "q", ".", "flags", "!=", "\"", "\"", "{", "x", "[", "\"", "\"", "]", "=", "q", ".", "flags", "\n", "}", "\n", "if", "q", ".", "maxDeterminizedStates", "!=", "nil", "{", "x", "[", "\"", "\"", "]", "=", "*", "q", ".", "maxDeterminizedStates", "\n", "}", "\n", "if", "q", ".", "boost", "!=", "nil", "{", "x", "[", "\"", "\"", "]", "=", "*", "q", ".", "boost", "\n", "}", "\n", "if", "q", ".", "rewrite", "!=", "\"", "\"", "{", "x", "[", "\"", "\"", "]", "=", "q", ".", "rewrite", "\n", "}", "\n", "if", "q", ".", "queryName", "!=", "\"", "\"", "{", "x", "[", "\"", "\"", "]", "=", "q", ".", "queryName", "\n", "}", "\n", "query", "[", "q", ".", "name", "]", "=", "x", "\n\n", "return", "source", ",", "nil", "\n", "}" ]
// Source returns the JSON-serializable query data.
[ "Source", "returns", "the", "JSON", "-", "serializable", "query", "data", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_regexp.go#L57-L82
train
olivere/elastic
sort.go
FieldName
func (s *FieldSort) FieldName(fieldName string) *FieldSort { s.fieldName = fieldName return s }
go
func (s *FieldSort) FieldName(fieldName string) *FieldSort { s.fieldName = fieldName return s }
[ "func", "(", "s", "*", "FieldSort", ")", "FieldName", "(", "fieldName", "string", ")", "*", "FieldSort", "{", "s", ".", "fieldName", "=", "fieldName", "\n", "return", "s", "\n", "}" ]
// FieldName specifies the name of the field to be used for sorting.
[ "FieldName", "specifies", "the", "name", "of", "the", "field", "to", "be", "used", "for", "sorting", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/sort.go#L176-L179
train
olivere/elastic
sort.go
Filter
func (s *FieldSort) Filter(filter Query) *FieldSort { s.filter = filter return s }
go
func (s *FieldSort) Filter(filter Query) *FieldSort { s.filter = filter return s }
[ "func", "(", "s", "*", "FieldSort", ")", "Filter", "(", "filter", "Query", ")", "*", "FieldSort", "{", "s", ".", "filter", "=", "filter", "\n", "return", "s", "\n", "}" ]
// Filter sets a filter that nested objects should match with // in order to be taken into account for sorting.
[ "Filter", "sets", "a", "filter", "that", "nested", "objects", "should", "match", "with", "in", "order", "to", "be", "taken", "into", "account", "for", "sorting", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/sort.go#L232-L235
train
olivere/elastic
sort.go
Path
func (s *FieldSort) Path(path string) *FieldSort { s.path = &path return s }
go
func (s *FieldSort) Path(path string) *FieldSort { s.path = &path return s }
[ "func", "(", "s", "*", "FieldSort", ")", "Path", "(", "path", "string", ")", "*", "FieldSort", "{", "s", ".", "path", "=", "&", "path", "\n", "return", "s", "\n", "}" ]
// Path is used if sorting occurs on a field that is inside a // nested object.
[ "Path", "is", "used", "if", "sorting", "occurs", "on", "a", "field", "that", "is", "inside", "a", "nested", "object", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/sort.go#L247-L250
train
olivere/elastic
sort.go
Nested
func (s *FieldSort) Nested(nested *NestedSort) *FieldSort { s.nested = nested return s }
go
func (s *FieldSort) Nested(nested *NestedSort) *FieldSort { s.nested = nested return s }
[ "func", "(", "s", "*", "FieldSort", ")", "Nested", "(", "nested", "*", "NestedSort", ")", "*", "FieldSort", "{", "s", ".", "nested", "=", "nested", "\n", "return", "s", "\n", "}" ]
// Nested is available starting with 6.1 and will replace Filter and Path.
[ "Nested", "is", "available", "starting", "with", "6", ".", "1", "and", "will", "replace", "Filter", "and", "Path", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/sort.go#L261-L264
train
olivere/elastic
sort.go
Type
func (s *ScriptSort) Type(typ string) *ScriptSort { s.typ = typ return s }
go
func (s *ScriptSort) Type(typ string) *ScriptSort { s.typ = typ return s }
[ "func", "(", "s", "*", "ScriptSort", ")", "Type", "(", "typ", "string", ")", "*", "ScriptSort", "{", "s", ".", "typ", "=", "typ", "\n", "return", "s", "\n", "}" ]
// Type sets the script type, which can be either "string" or "number".
[ "Type", "sets", "the", "script", "type", "which", "can", "be", "either", "string", "or", "number", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/sort.go#L501-L504
train
olivere/elastic
sort.go
Filter
func (s *NestedSort) Filter(filter Query) *NestedSort { s.filter = filter return s }
go
func (s *NestedSort) Filter(filter Query) *NestedSort { s.filter = filter return s }
[ "func", "(", "s", "*", "NestedSort", ")", "Filter", "(", "filter", "Query", ")", "*", "NestedSort", "{", "s", ".", "filter", "=", "filter", "\n", "return", "s", "\n", "}" ]
// Filter sets the filter.
[ "Filter", "sets", "the", "filter", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/sort.go#L620-L623
train
olivere/elastic
sort.go
NestedSort
func (s *NestedSort) NestedSort(nestedSort *NestedSort) *NestedSort { s.nestedSort = nestedSort return s }
go
func (s *NestedSort) NestedSort(nestedSort *NestedSort) *NestedSort { s.nestedSort = nestedSort return s }
[ "func", "(", "s", "*", "NestedSort", ")", "NestedSort", "(", "nestedSort", "*", "NestedSort", ")", "*", "NestedSort", "{", "s", ".", "nestedSort", "=", "nestedSort", "\n", "return", "s", "\n", "}" ]
// NestedSort embeds another level of nested sorting.
[ "NestedSort", "embeds", "another", "level", "of", "nested", "sorting", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/sort.go#L626-L629
train
olivere/elastic
search_queries_match_phrase_prefix.go
NewMatchPhrasePrefixQuery
func NewMatchPhrasePrefixQuery(name string, value interface{}) *MatchPhrasePrefixQuery { return &MatchPhrasePrefixQuery{name: name, value: value} }
go
func NewMatchPhrasePrefixQuery(name string, value interface{}) *MatchPhrasePrefixQuery { return &MatchPhrasePrefixQuery{name: name, value: value} }
[ "func", "NewMatchPhrasePrefixQuery", "(", "name", "string", ",", "value", "interface", "{", "}", ")", "*", "MatchPhrasePrefixQuery", "{", "return", "&", "MatchPhrasePrefixQuery", "{", "name", ":", "name", ",", "value", ":", "value", "}", "\n", "}" ]
// NewMatchPhrasePrefixQuery creates and initializes a new MatchPhrasePrefixQuery.
[ "NewMatchPhrasePrefixQuery", "creates", "and", "initializes", "a", "new", "MatchPhrasePrefixQuery", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_match_phrase_prefix.go#L23-L25
train
olivere/elastic
search_queries_match_phrase_prefix.go
MaxExpansions
func (q *MatchPhrasePrefixQuery) MaxExpansions(n int) *MatchPhrasePrefixQuery { q.maxExpansions = &n return q }
go
func (q *MatchPhrasePrefixQuery) MaxExpansions(n int) *MatchPhrasePrefixQuery { q.maxExpansions = &n return q }
[ "func", "(", "q", "*", "MatchPhrasePrefixQuery", ")", "MaxExpansions", "(", "n", "int", ")", "*", "MatchPhrasePrefixQuery", "{", "q", ".", "maxExpansions", "=", "&", "n", "\n", "return", "q", "\n", "}" ]
// MaxExpansions sets the number of term expansions to use.
[ "MaxExpansions", "sets", "the", "number", "of", "term", "expansions", "to", "use", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_match_phrase_prefix.go#L41-L44
train
olivere/elastic
search_queries_slice.go
Id
func (s *SliceQuery) Id(id int) *SliceQuery { s.id = &id return s }
go
func (s *SliceQuery) Id(id int) *SliceQuery { s.id = &id return s }
[ "func", "(", "s", "*", "SliceQuery", ")", "Id", "(", "id", "int", ")", "*", "SliceQuery", "{", "s", ".", "id", "=", "&", "id", "\n", "return", "s", "\n", "}" ]
// Id is the id of the slice.
[ "Id", "is", "the", "id", "of", "the", "slice", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_slice.go#L29-L32
train
olivere/elastic
search_queries_slice.go
Max
func (s *SliceQuery) Max(max int) *SliceQuery { s.max = &max return s }
go
func (s *SliceQuery) Max(max int) *SliceQuery { s.max = &max return s }
[ "func", "(", "s", "*", "SliceQuery", ")", "Max", "(", "max", "int", ")", "*", "SliceQuery", "{", "s", ".", "max", "=", "&", "max", "\n", "return", "s", "\n", "}" ]
// Max is the maximum number of slices.
[ "Max", "is", "the", "maximum", "number", "of", "slices", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_slice.go#L35-L38
train
olivere/elastic
search_queries_slice.go
Source
func (s *SliceQuery) Source() (interface{}, error) { m := make(map[string]interface{}) if s.field != "" { m["field"] = s.field } if s.id != nil { m["id"] = *s.id } if s.max != nil { m["max"] = *s.max } return m, nil }
go
func (s *SliceQuery) Source() (interface{}, error) { m := make(map[string]interface{}) if s.field != "" { m["field"] = s.field } if s.id != nil { m["id"] = *s.id } if s.max != nil { m["max"] = *s.max } return m, nil }
[ "func", "(", "s", "*", "SliceQuery", ")", "Source", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "if", "s", ".", "field", "!=", "\"", "\"", "{", "m", "[", "\"", "\"", "]", "=", "s", ".", "field", "\n", "}", "\n", "if", "s", ".", "id", "!=", "nil", "{", "m", "[", "\"", "\"", "]", "=", "*", "s", ".", "id", "\n", "}", "\n", "if", "s", ".", "max", "!=", "nil", "{", "m", "[", "\"", "\"", "]", "=", "*", "s", ".", "max", "\n", "}", "\n", "return", "m", ",", "nil", "\n", "}" ]
// Source returns the JSON body.
[ "Source", "returns", "the", "JSON", "body", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_slice.go#L41-L53
train
olivere/elastic
field_caps.go
Fields
func (s *FieldCapsService) Fields(fields ...string) *FieldCapsService { s.fields = append(s.fields, fields...) return s }
go
func (s *FieldCapsService) Fields(fields ...string) *FieldCapsService { s.fields = append(s.fields, fields...) return s }
[ "func", "(", "s", "*", "FieldCapsService", ")", "Fields", "(", "fields", "...", "string", ")", "*", "FieldCapsService", "{", "s", ".", "fields", "=", "append", "(", "s", ".", "fields", ",", "fields", "...", ")", "\n", "return", "s", "\n", "}" ]
// Fields is a list of fields for to get field capabilities.
[ "Fields", "is", "a", "list", "of", "fields", "for", "to", "get", "field", "capabilities", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/field_caps.go#L63-L66
train
olivere/elastic
count.go
Df
func (s *CountService) Df(df string) *CountService { s.df = df return s }
go
func (s *CountService) Df(df string) *CountService { s.df = df return s }
[ "func", "(", "s", "*", "CountService", ")", "Df", "(", "df", "string", ")", "*", "CountService", "{", "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/count.go#L100-L103
train
olivere/elastic
count.go
Q
func (s *CountService) Q(q string) *CountService { s.q = q return s }
go
func (s *CountService) Q(q string) *CountService { s.q = q return s }
[ "func", "(", "s", "*", "CountService", ")", "Q", "(", "q", "string", ")", "*", "CountService", "{", "s", ".", "q", "=", "q", "\n", "return", "s", "\n", "}" ]
// Q in the Lucene query string syntax. You can also use Query to pass // a Query struct.
[ "Q", "in", "the", "Lucene", "query", "string", "syntax", ".", "You", "can", "also", "use", "Query", "to", "pass", "a", "Query", "struct", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/count.go#L148-L151
train
olivere/elastic
count.go
Query
func (s *CountService) Query(query Query) *CountService { s.query = query return s }
go
func (s *CountService) Query(query Query) *CountService { s.query = query return s }
[ "func", "(", "s", "*", "CountService", ")", "Query", "(", "query", "Query", ")", "*", "CountService", "{", "s", ".", "query", "=", "query", "\n", "return", "s", "\n", "}" ]
// Query specifies the query to pass. You can also pass a query string with Q.
[ "Query", "specifies", "the", "query", "to", "pass", ".", "You", "can", "also", "pass", "a", "query", "string", "with", "Q", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/count.go#L154-L157
train
olivere/elastic
count.go
TerminateAfter
func (s *CountService) TerminateAfter(terminateAfter int) *CountService { s.terminateAfter = &terminateAfter return s }
go
func (s *CountService) TerminateAfter(terminateAfter int) *CountService { s.terminateAfter = &terminateAfter return s }
[ "func", "(", "s", "*", "CountService", ")", "TerminateAfter", "(", "terminateAfter", "int", ")", "*", "CountService", "{", "s", ".", "terminateAfter", "=", "&", "terminateAfter", "\n", "return", "s", "\n", "}" ]
// TerminateAfter indicates the maximum count for each shard, upon reaching // which the query execution will terminate early.
[ "TerminateAfter", "indicates", "the", "maximum", "count", "for", "each", "shard", "upon", "reaching", "which", "the", "query", "execution", "will", "terminate", "early", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/count.go#L167-L170
train
olivere/elastic
mtermvectors.go
Add
func (s *MultiTermvectorService) Add(docs ...*MultiTermvectorItem) *MultiTermvectorService { s.docs = append(s.docs, docs...) return s }
go
func (s *MultiTermvectorService) Add(docs ...*MultiTermvectorItem) *MultiTermvectorService { s.docs = append(s.docs, docs...) return s }
[ "func", "(", "s", "*", "MultiTermvectorService", ")", "Add", "(", "docs", "...", "*", "MultiTermvectorItem", ")", "*", "MultiTermvectorService", "{", "s", ".", "docs", "=", "append", "(", "s", ".", "docs", ",", "docs", "...", ")", "\n", "return", "s", "\n", "}" ]
// Add adds documents to MultiTermvectors service.
[ "Add", "adds", "documents", "to", "MultiTermvectors", "service", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L60-L63
train
olivere/elastic
mtermvectors.go
Type
func (s *MultiTermvectorService) Type(typ string) *MultiTermvectorService { s.typ = typ return s }
go
func (s *MultiTermvectorService) Type(typ string) *MultiTermvectorService { s.typ = typ return s }
[ "func", "(", "s", "*", "MultiTermvectorService", ")", "Type", "(", "typ", "string", ")", "*", "MultiTermvectorService", "{", "s", ".", "typ", "=", "typ", "\n", "return", "s", "\n", "}" ]
// Type of the document.
[ "Type", "of", "the", "document", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L72-L75
train
olivere/elastic
mtermvectors.go
FieldStatistics
func (s *MultiTermvectorService) FieldStatistics(fieldStatistics bool) *MultiTermvectorService { s.fieldStatistics = &fieldStatistics return s }
go
func (s *MultiTermvectorService) FieldStatistics(fieldStatistics bool) *MultiTermvectorService { s.fieldStatistics = &fieldStatistics return s }
[ "func", "(", "s", "*", "MultiTermvectorService", ")", "FieldStatistics", "(", "fieldStatistics", "bool", ")", "*", "MultiTermvectorService", "{", "s", ".", "fieldStatistics", "=", "&", "fieldStatistics", "\n", "return", "s", "\n", "}" ]
// FieldStatistics specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
[ "FieldStatistics", "specifies", "if", "document", "count", "sum", "of", "document", "frequencies", "and", "sum", "of", "total", "term", "frequencies", "should", "be", "returned", ".", "Applies", "to", "all", "returned", "documents", "unless", "otherwise", "specified", "in", "body", "params", "or", "docs", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L78-L81
train
olivere/elastic
mtermvectors.go
Fields
func (s *MultiTermvectorService) Fields(fields []string) *MultiTermvectorService { s.fields = fields return s }
go
func (s *MultiTermvectorService) Fields(fields []string) *MultiTermvectorService { s.fields = fields return s }
[ "func", "(", "s", "*", "MultiTermvectorService", ")", "Fields", "(", "fields", "[", "]", "string", ")", "*", "MultiTermvectorService", "{", "s", ".", "fields", "=", "fields", "\n", "return", "s", "\n", "}" ]
// Fields is a comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs".
[ "Fields", "is", "a", "comma", "-", "separated", "list", "of", "fields", "to", "return", ".", "Applies", "to", "all", "returned", "documents", "unless", "otherwise", "specified", "in", "body", "params", "or", "docs", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L84-L87
train
olivere/elastic
mtermvectors.go
Ids
func (s *MultiTermvectorService) Ids(ids []string) *MultiTermvectorService { s.ids = ids return s }
go
func (s *MultiTermvectorService) Ids(ids []string) *MultiTermvectorService { s.ids = ids return s }
[ "func", "(", "s", "*", "MultiTermvectorService", ")", "Ids", "(", "ids", "[", "]", "string", ")", "*", "MultiTermvectorService", "{", "s", ".", "ids", "=", "ids", "\n", "return", "s", "\n", "}" ]
// Ids is a comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body.
[ "Ids", "is", "a", "comma", "-", "separated", "list", "of", "documents", "ids", ".", "You", "must", "define", "ids", "as", "parameter", "or", "set", "ids", "or", "docs", "in", "the", "request", "body", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L90-L93
train
olivere/elastic
mtermvectors.go
Offsets
func (s *MultiTermvectorService) Offsets(offsets bool) *MultiTermvectorService { s.offsets = &offsets return s }
go
func (s *MultiTermvectorService) Offsets(offsets bool) *MultiTermvectorService { s.offsets = &offsets return s }
[ "func", "(", "s", "*", "MultiTermvectorService", ")", "Offsets", "(", "offsets", "bool", ")", "*", "MultiTermvectorService", "{", "s", ".", "offsets", "=", "&", "offsets", "\n", "return", "s", "\n", "}" ]
// Offsets specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
[ "Offsets", "specifies", "if", "term", "offsets", "should", "be", "returned", ".", "Applies", "to", "all", "returned", "documents", "unless", "otherwise", "specified", "in", "body", "params", "or", "docs", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L96-L99
train
olivere/elastic
mtermvectors.go
Parent
func (s *MultiTermvectorService) Parent(parent string) *MultiTermvectorService { s.parent = parent return s }
go
func (s *MultiTermvectorService) Parent(parent string) *MultiTermvectorService { s.parent = parent return s }
[ "func", "(", "s", "*", "MultiTermvectorService", ")", "Parent", "(", "parent", "string", ")", "*", "MultiTermvectorService", "{", "s", ".", "parent", "=", "parent", "\n", "return", "s", "\n", "}" ]
// Parent id of documents. Applies to all returned documents unless otherwise specified in body "params" or "docs".
[ "Parent", "id", "of", "documents", ".", "Applies", "to", "all", "returned", "documents", "unless", "otherwise", "specified", "in", "body", "params", "or", "docs", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L102-L105
train
olivere/elastic
mtermvectors.go
Payloads
func (s *MultiTermvectorService) Payloads(payloads bool) *MultiTermvectorService { s.payloads = &payloads return s }
go
func (s *MultiTermvectorService) Payloads(payloads bool) *MultiTermvectorService { s.payloads = &payloads return s }
[ "func", "(", "s", "*", "MultiTermvectorService", ")", "Payloads", "(", "payloads", "bool", ")", "*", "MultiTermvectorService", "{", "s", ".", "payloads", "=", "&", "payloads", "\n", "return", "s", "\n", "}" ]
// Payloads specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
[ "Payloads", "specifies", "if", "term", "payloads", "should", "be", "returned", ".", "Applies", "to", "all", "returned", "documents", "unless", "otherwise", "specified", "in", "body", "params", "or", "docs", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L108-L111
train
olivere/elastic
mtermvectors.go
Positions
func (s *MultiTermvectorService) Positions(positions bool) *MultiTermvectorService { s.positions = &positions return s }
go
func (s *MultiTermvectorService) Positions(positions bool) *MultiTermvectorService { s.positions = &positions return s }
[ "func", "(", "s", "*", "MultiTermvectorService", ")", "Positions", "(", "positions", "bool", ")", "*", "MultiTermvectorService", "{", "s", ".", "positions", "=", "&", "positions", "\n", "return", "s", "\n", "}" ]
// Positions specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
[ "Positions", "specifies", "if", "term", "positions", "should", "be", "returned", ".", "Applies", "to", "all", "returned", "documents", "unless", "otherwise", "specified", "in", "body", "params", "or", "docs", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L114-L117
train
olivere/elastic
mtermvectors.go
Routing
func (s *MultiTermvectorService) Routing(routing string) *MultiTermvectorService { s.routing = routing return s }
go
func (s *MultiTermvectorService) Routing(routing string) *MultiTermvectorService { s.routing = routing return s }
[ "func", "(", "s", "*", "MultiTermvectorService", ")", "Routing", "(", "routing", "string", ")", "*", "MultiTermvectorService", "{", "s", ".", "routing", "=", "routing", "\n", "return", "s", "\n", "}" ]
// Routing specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs".
[ "Routing", "specific", "routing", "value", ".", "Applies", "to", "all", "returned", "documents", "unless", "otherwise", "specified", "in", "body", "params", "or", "docs", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L132-L135
train
olivere/elastic
mtermvectors.go
TermStatistics
func (s *MultiTermvectorService) TermStatistics(termStatistics bool) *MultiTermvectorService { s.termStatistics = &termStatistics return s }
go
func (s *MultiTermvectorService) TermStatistics(termStatistics bool) *MultiTermvectorService { s.termStatistics = &termStatistics return s }
[ "func", "(", "s", "*", "MultiTermvectorService", ")", "TermStatistics", "(", "termStatistics", "bool", ")", "*", "MultiTermvectorService", "{", "s", ".", "termStatistics", "=", "&", "termStatistics", "\n", "return", "s", "\n", "}" ]
// TermStatistics specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
[ "TermStatistics", "specifies", "if", "total", "term", "frequency", "and", "document", "frequency", "should", "be", "returned", ".", "Applies", "to", "all", "returned", "documents", "unless", "otherwise", "specified", "in", "body", "params", "or", "docs", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L138-L141
train
olivere/elastic
mtermvectors.go
VersionType
func (s *MultiTermvectorService) VersionType(versionType string) *MultiTermvectorService { s.versionType = versionType return s }
go
func (s *MultiTermvectorService) VersionType(versionType string) *MultiTermvectorService { s.versionType = versionType return s }
[ "func", "(", "s", "*", "MultiTermvectorService", ")", "VersionType", "(", "versionType", "string", ")", "*", "MultiTermvectorService", "{", "s", ".", "versionType", "=", "versionType", "\n", "return", "s", "\n", "}" ]
// VersionType is specific version type.
[ "VersionType", "is", "specific", "version", "type", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L150-L153
train
olivere/elastic
mtermvectors.go
Source
func (s *MultiTermvectorItem) Source() interface{} { source := make(map[string]interface{}) source["_id"] = s.id if s.index != "" { source["_index"] = s.index } if s.typ != "" { source["_type"] = s.typ } if s.fields != nil { source["fields"] = s.fields } if s.fieldStatistics != nil { source["field_statistics"] = fmt.Sprintf("%v", *s.fieldStatistics) } if s.offsets != nil { source["offsets"] = s.offsets } if s.parent != "" { source["parent"] = s.parent } if s.payloads != nil { source["payloads"] = fmt.Sprintf("%v", *s.payloads) } if s.positions != nil { source["positions"] = fmt.Sprintf("%v", *s.positions) } if s.preference != "" { source["preference"] = s.preference } if s.realtime != nil { source["realtime"] = fmt.Sprintf("%v", *s.realtime) } if s.routing != "" { source["routing"] = s.routing } if s.termStatistics != nil { source["term_statistics"] = fmt.Sprintf("%v", *s.termStatistics) } if s.doc != nil { source["doc"] = s.doc } if s.perFieldAnalyzer != nil && len(s.perFieldAnalyzer) > 0 { source["per_field_analyzer"] = s.perFieldAnalyzer } return source }
go
func (s *MultiTermvectorItem) Source() interface{} { source := make(map[string]interface{}) source["_id"] = s.id if s.index != "" { source["_index"] = s.index } if s.typ != "" { source["_type"] = s.typ } if s.fields != nil { source["fields"] = s.fields } if s.fieldStatistics != nil { source["field_statistics"] = fmt.Sprintf("%v", *s.fieldStatistics) } if s.offsets != nil { source["offsets"] = s.offsets } if s.parent != "" { source["parent"] = s.parent } if s.payloads != nil { source["payloads"] = fmt.Sprintf("%v", *s.payloads) } if s.positions != nil { source["positions"] = fmt.Sprintf("%v", *s.positions) } if s.preference != "" { source["preference"] = s.preference } if s.realtime != nil { source["realtime"] = fmt.Sprintf("%v", *s.realtime) } if s.routing != "" { source["routing"] = s.routing } if s.termStatistics != nil { source["term_statistics"] = fmt.Sprintf("%v", *s.termStatistics) } if s.doc != nil { source["doc"] = s.doc } if s.perFieldAnalyzer != nil && len(s.perFieldAnalyzer) > 0 { source["per_field_analyzer"] = s.perFieldAnalyzer } return source }
[ "func", "(", "s", "*", "MultiTermvectorItem", ")", "Source", "(", ")", "interface", "{", "}", "{", "source", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n\n", "source", "[", "\"", "\"", "]", "=", "s", ".", "id", "\n\n", "if", "s", ".", "index", "!=", "\"", "\"", "{", "source", "[", "\"", "\"", "]", "=", "s", ".", "index", "\n", "}", "\n", "if", "s", ".", "typ", "!=", "\"", "\"", "{", "source", "[", "\"", "\"", "]", "=", "s", ".", "typ", "\n", "}", "\n", "if", "s", ".", "fields", "!=", "nil", "{", "source", "[", "\"", "\"", "]", "=", "s", ".", "fields", "\n", "}", "\n", "if", "s", ".", "fieldStatistics", "!=", "nil", "{", "source", "[", "\"", "\"", "]", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "*", "s", ".", "fieldStatistics", ")", "\n", "}", "\n", "if", "s", ".", "offsets", "!=", "nil", "{", "source", "[", "\"", "\"", "]", "=", "s", ".", "offsets", "\n", "}", "\n", "if", "s", ".", "parent", "!=", "\"", "\"", "{", "source", "[", "\"", "\"", "]", "=", "s", ".", "parent", "\n", "}", "\n", "if", "s", ".", "payloads", "!=", "nil", "{", "source", "[", "\"", "\"", "]", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "*", "s", ".", "payloads", ")", "\n", "}", "\n", "if", "s", ".", "positions", "!=", "nil", "{", "source", "[", "\"", "\"", "]", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "*", "s", ".", "positions", ")", "\n", "}", "\n", "if", "s", ".", "preference", "!=", "\"", "\"", "{", "source", "[", "\"", "\"", "]", "=", "s", ".", "preference", "\n", "}", "\n", "if", "s", ".", "realtime", "!=", "nil", "{", "source", "[", "\"", "\"", "]", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "*", "s", ".", "realtime", ")", "\n", "}", "\n", "if", "s", ".", "routing", "!=", "\"", "\"", "{", "source", "[", "\"", "\"", "]", "=", "s", ".", "routing", "\n", "}", "\n", "if", "s", ".", "termStatistics", "!=", "nil", "{", "source", "[", "\"", "\"", "]", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "*", "s", ".", "termStatistics", ")", "\n", "}", "\n", "if", "s", ".", "doc", "!=", "nil", "{", "source", "[", "\"", "\"", "]", "=", "s", ".", "doc", "\n", "}", "\n", "if", "s", ".", "perFieldAnalyzer", "!=", "nil", "&&", "len", "(", "s", ".", "perFieldAnalyzer", ")", ">", "0", "{", "source", "[", "\"", "\"", "]", "=", "s", ".", "perFieldAnalyzer", "\n", "}", "\n\n", "return", "source", "\n", "}" ]
// Source returns the serialized JSON to be sent to Elasticsearch as // part of a MultiTermvector.
[ "Source", "returns", "the", "serialized", "JSON", "to", "be", "sent", "to", "Elasticsearch", "as", "part", "of", "a", "MultiTermvector", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/mtermvectors.go#L426-L475
train
olivere/elastic
search_terms_lookup.go
Index
func (t *TermsLookup) Index(index string) *TermsLookup { t.index = index return t }
go
func (t *TermsLookup) Index(index string) *TermsLookup { t.index = index return t }
[ "func", "(", "t", "*", "TermsLookup", ")", "Index", "(", "index", "string", ")", "*", "TermsLookup", "{", "t", ".", "index", "=", "index", "\n", "return", "t", "\n", "}" ]
// Index name.
[ "Index", "name", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_terms_lookup.go#L26-L29
train
olivere/elastic
search_terms_lookup.go
Id
func (t *TermsLookup) Id(id string) *TermsLookup { t.id = id return t }
go
func (t *TermsLookup) Id(id string) *TermsLookup { t.id = id return t }
[ "func", "(", "t", "*", "TermsLookup", ")", "Id", "(", "id", "string", ")", "*", "TermsLookup", "{", "t", ".", "id", "=", "id", "\n", "return", "t", "\n", "}" ]
// Id to look up.
[ "Id", "to", "look", "up", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_terms_lookup.go#L40-L43
train
olivere/elastic
search_terms_lookup.go
Path
func (t *TermsLookup) Path(path string) *TermsLookup { t.path = path return t }
go
func (t *TermsLookup) Path(path string) *TermsLookup { t.path = path return t }
[ "func", "(", "t", "*", "TermsLookup", ")", "Path", "(", "path", "string", ")", "*", "TermsLookup", "{", "t", ".", "path", "=", "path", "\n", "return", "t", "\n", "}" ]
// Path to use for lookup.
[ "Path", "to", "use", "for", "lookup", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_terms_lookup.go#L46-L49
train
olivere/elastic
search_terms_lookup.go
Routing
func (t *TermsLookup) Routing(routing string) *TermsLookup { t.routing = routing return t }
go
func (t *TermsLookup) Routing(routing string) *TermsLookup { t.routing = routing return t }
[ "func", "(", "t", "*", "TermsLookup", ")", "Routing", "(", "routing", "string", ")", "*", "TermsLookup", "{", "t", ".", "routing", "=", "routing", "\n", "return", "t", "\n", "}" ]
// Routing value.
[ "Routing", "value", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_terms_lookup.go#L52-L55
train
olivere/elastic
search_terms_lookup.go
Source
func (t *TermsLookup) Source() (interface{}, error) { src := make(map[string]interface{}) if t.index != "" { src["index"] = t.index } if t.typ != "" { src["type"] = t.typ } if t.id != "" { src["id"] = t.id } if t.path != "" { src["path"] = t.path } if t.routing != "" { src["routing"] = t.routing } return src, nil }
go
func (t *TermsLookup) Source() (interface{}, error) { src := make(map[string]interface{}) if t.index != "" { src["index"] = t.index } if t.typ != "" { src["type"] = t.typ } if t.id != "" { src["id"] = t.id } if t.path != "" { src["path"] = t.path } if t.routing != "" { src["routing"] = t.routing } return src, nil }
[ "func", "(", "t", "*", "TermsLookup", ")", "Source", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "src", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "if", "t", ".", "index", "!=", "\"", "\"", "{", "src", "[", "\"", "\"", "]", "=", "t", ".", "index", "\n", "}", "\n", "if", "t", ".", "typ", "!=", "\"", "\"", "{", "src", "[", "\"", "\"", "]", "=", "t", ".", "typ", "\n", "}", "\n", "if", "t", ".", "id", "!=", "\"", "\"", "{", "src", "[", "\"", "\"", "]", "=", "t", ".", "id", "\n", "}", "\n", "if", "t", ".", "path", "!=", "\"", "\"", "{", "src", "[", "\"", "\"", "]", "=", "t", ".", "path", "\n", "}", "\n", "if", "t", ".", "routing", "!=", "\"", "\"", "{", "src", "[", "\"", "\"", "]", "=", "t", ".", "routing", "\n", "}", "\n", "return", "src", ",", "nil", "\n", "}" ]
// Source creates the JSON source of the builder.
[ "Source", "creates", "the", "JSON", "source", "of", "the", "builder", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_terms_lookup.go#L58-L76
train
olivere/elastic
indices_get_settings.go
NewIndicesGetSettingsService
func NewIndicesGetSettingsService(client *Client) *IndicesGetSettingsService { return &IndicesGetSettingsService{ client: client, index: make([]string, 0), name: make([]string, 0), } }
go
func NewIndicesGetSettingsService(client *Client) *IndicesGetSettingsService { return &IndicesGetSettingsService{ client: client, index: make([]string, 0), name: make([]string, 0), } }
[ "func", "NewIndicesGetSettingsService", "(", "client", "*", "Client", ")", "*", "IndicesGetSettingsService", "{", "return", "&", "IndicesGetSettingsService", "{", "client", ":", "client", ",", "index", ":", "make", "(", "[", "]", "string", ",", "0", ")", ",", "name", ":", "make", "(", "[", "]", "string", ",", "0", ")", ",", "}", "\n", "}" ]
// NewIndicesGetSettingsService creates a new IndicesGetSettingsService.
[ "NewIndicesGetSettingsService", "creates", "a", "new", "IndicesGetSettingsService", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_get_settings.go#L34-L40
train
olivere/elastic
indices_get_settings.go
Name
func (s *IndicesGetSettingsService) Name(name ...string) *IndicesGetSettingsService { s.name = append(s.name, name...) return s }
go
func (s *IndicesGetSettingsService) Name(name ...string) *IndicesGetSettingsService { s.name = append(s.name, name...) return s }
[ "func", "(", "s", "*", "IndicesGetSettingsService", ")", "Name", "(", "name", "...", "string", ")", "*", "IndicesGetSettingsService", "{", "s", ".", "name", "=", "append", "(", "s", ".", "name", ",", "name", "...", ")", "\n", "return", "s", "\n", "}" ]
// Name are the names of the settings that should be included.
[ "Name", "are", "the", "names", "of", "the", "settings", "that", "should", "be", "included", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/indices_get_settings.go#L50-L53
train
olivere/elastic
search_queries_fsq_score_funcs.go
Script
func (fn *ScriptFunction) Script(script *Script) *ScriptFunction { fn.script = script return fn }
go
func (fn *ScriptFunction) Script(script *Script) *ScriptFunction { fn.script = script return fn }
[ "func", "(", "fn", "*", "ScriptFunction", ")", "Script", "(", "script", "*", "Script", ")", "*", "ScriptFunction", "{", "fn", ".", "script", "=", "script", "\n", "return", "fn", "\n", "}" ]
// Script specifies the script to be executed.
[ "Script", "specifies", "the", "script", "to", "be", "executed", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_fsq_score_funcs.go#L360-L363
train
olivere/elastic
search_queries_fsq_score_funcs.go
Missing
func (fn *FieldValueFactorFunction) Missing(missing float64) *FieldValueFactorFunction { fn.missing = &missing return fn }
go
func (fn *FieldValueFactorFunction) Missing(missing float64) *FieldValueFactorFunction { fn.missing = &missing return fn }
[ "func", "(", "fn", "*", "FieldValueFactorFunction", ")", "Missing", "(", "missing", "float64", ")", "*", "FieldValueFactorFunction", "{", "fn", ".", "missing", "=", "&", "missing", "\n", "return", "fn", "\n", "}" ]
// Missing is used if a document does not have that field.
[ "Missing", "is", "used", "if", "a", "document", "does", "not", "have", "that", "field", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_fsq_score_funcs.go#L452-L455
train
olivere/elastic
search_queries_fsq_score_funcs.go
Field
func (fn *RandomFunction) Field(field string) *RandomFunction { fn.field = field return fn }
go
func (fn *RandomFunction) Field(field string) *RandomFunction { fn.field = field return fn }
[ "func", "(", "fn", "*", "RandomFunction", ")", "Field", "(", "field", "string", ")", "*", "RandomFunction", "{", "fn", ".", "field", "=", "field", "\n", "return", "fn", "\n", "}" ]
// Field is the field to be used for random number generation. // This parameter is compulsory when a Seed is set and ignored // otherwise. Note that documents that have the same value for a // field will get the same score.
[ "Field", "is", "the", "field", "to", "be", "used", "for", "random", "number", "generation", ".", "This", "parameter", "is", "compulsory", "when", "a", "Seed", "is", "set", "and", "ignored", "otherwise", ".", "Note", "that", "documents", "that", "have", "the", "same", "value", "for", "a", "field", "will", "get", "the", "same", "score", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/search_queries_fsq_score_funcs.go#L543-L546
train
olivere/elastic
cluster_state.go
NewClusterStateService
func NewClusterStateService(client *Client) *ClusterStateService { return &ClusterStateService{ client: client, indices: make([]string, 0), metrics: make([]string, 0), } }
go
func NewClusterStateService(client *Client) *ClusterStateService { return &ClusterStateService{ client: client, indices: make([]string, 0), metrics: make([]string, 0), } }
[ "func", "NewClusterStateService", "(", "client", "*", "Client", ")", "*", "ClusterStateService", "{", "return", "&", "ClusterStateService", "{", "client", ":", "client", ",", "indices", ":", "make", "(", "[", "]", "string", ",", "0", ")", ",", "metrics", ":", "make", "(", "[", "]", "string", ",", "0", ")", ",", "}", "\n", "}" ]
// NewClusterStateService creates a new ClusterStateService.
[ "NewClusterStateService", "creates", "a", "new", "ClusterStateService", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/cluster_state.go#L34-L40
train
olivere/elastic
cluster_state.go
Index
func (s *ClusterStateService) Index(indices ...string) *ClusterStateService { s.indices = append(s.indices, indices...) return s }
go
func (s *ClusterStateService) Index(indices ...string) *ClusterStateService { s.indices = append(s.indices, indices...) return s }
[ "func", "(", "s", "*", "ClusterStateService", ")", "Index", "(", "indices", "...", "string", ")", "*", "ClusterStateService", "{", "s", ".", "indices", "=", "append", "(", "s", ".", "indices", ",", "indices", "...", ")", "\n", "return", "s", "\n", "}" ]
// Index is a list of index names. Use _all or an empty string to // perform the operation on all indices.
[ "Index", "is", "a", "list", "of", "index", "names", ".", "Use", "_all", "or", "an", "empty", "string", "to", "perform", "the", "operation", "on", "all", "indices", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/cluster_state.go#L44-L47
train
olivere/elastic
cluster_state.go
MasterTimeout
func (s *ClusterStateService) MasterTimeout(masterTimeout string) *ClusterStateService { s.masterTimeout = masterTimeout return s }
go
func (s *ClusterStateService) MasterTimeout(masterTimeout string) *ClusterStateService { s.masterTimeout = masterTimeout return s }
[ "func", "(", "s", "*", "ClusterStateService", ")", "MasterTimeout", "(", "masterTimeout", "string", ")", "*", "ClusterStateService", "{", "s", ".", "masterTimeout", "=", "masterTimeout", "\n", "return", "s", "\n", "}" ]
// MasterTimeout specifies timeout for connection to master.
[ "MasterTimeout", "specifies", "timeout", "for", "connection", "to", "master", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/cluster_state.go#L93-L96
train
olivere/elastic
xpack_watcher_activate_watch.go
WatchId
func (s *XPackWatcherActivateWatchService) WatchId(watchId string) *XPackWatcherActivateWatchService { s.watchId = watchId return s }
go
func (s *XPackWatcherActivateWatchService) WatchId(watchId string) *XPackWatcherActivateWatchService { s.watchId = watchId return s }
[ "func", "(", "s", "*", "XPackWatcherActivateWatchService", ")", "WatchId", "(", "watchId", "string", ")", "*", "XPackWatcherActivateWatchService", "{", "s", ".", "watchId", "=", "watchId", "\n", "return", "s", "\n", "}" ]
// WatchId is the ID of the watch to activate.
[ "WatchId", "is", "the", "ID", "of", "the", "watch", "to", "activate", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/xpack_watcher_activate_watch.go#L33-L36
train
olivere/elastic
clear_scroll.go
NewClearScrollService
func NewClearScrollService(client *Client) *ClearScrollService { return &ClearScrollService{ client: client, scrollId: make([]string, 0), } }
go
func NewClearScrollService(client *Client) *ClearScrollService { return &ClearScrollService{ client: client, scrollId: make([]string, 0), } }
[ "func", "NewClearScrollService", "(", "client", "*", "Client", ")", "*", "ClearScrollService", "{", "return", "&", "ClearScrollService", "{", "client", ":", "client", ",", "scrollId", ":", "make", "(", "[", "]", "string", ",", "0", ")", ",", "}", "\n", "}" ]
// NewClearScrollService creates a new ClearScrollService.
[ "NewClearScrollService", "creates", "a", "new", "ClearScrollService", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/clear_scroll.go#L24-L29
train
olivere/elastic
client.go
NewClientFromConfig
func NewClientFromConfig(cfg *config.Config) (*Client, error) { options, err := configToOptions(cfg) if err != nil { return nil, err } return DialContext(context.Background(), options...) }
go
func NewClientFromConfig(cfg *config.Config) (*Client, error) { options, err := configToOptions(cfg) if err != nil { return nil, err } return DialContext(context.Background(), options...) }
[ "func", "NewClientFromConfig", "(", "cfg", "*", "config", ".", "Config", ")", "(", "*", "Client", ",", "error", ")", "{", "options", ",", "err", ":=", "configToOptions", "(", "cfg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "DialContext", "(", "context", ".", "Background", "(", ")", ",", "options", "...", ")", "\n", "}" ]
// NewClientFromConfig initializes a client from a configuration.
[ "NewClientFromConfig", "initializes", "a", "client", "from", "a", "configuration", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L197-L203
train
olivere/elastic
client.go
SetHttpClient
func SetHttpClient(httpClient *http.Client) ClientOptionFunc { return func(c *Client) error { if httpClient != nil { c.c = httpClient } else { c.c = http.DefaultClient } return nil } }
go
func SetHttpClient(httpClient *http.Client) ClientOptionFunc { return func(c *Client) error { if httpClient != nil { c.c = httpClient } else { c.c = http.DefaultClient } return nil } }
[ "func", "SetHttpClient", "(", "httpClient", "*", "http", ".", "Client", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "if", "httpClient", "!=", "nil", "{", "c", ".", "c", "=", "httpClient", "\n", "}", "else", "{", "c", ".", "c", "=", "http", ".", "DefaultClient", "\n", "}", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetHttpClient can be used to specify the http.Client to use when making // HTTP requests to Elasticsearch.
[ "SetHttpClient", "can", "be", "used", "to", "specify", "the", "http", ".", "Client", "to", "use", "when", "making", "HTTP", "requests", "to", "Elasticsearch", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L466-L475
train
olivere/elastic
client.go
SetBasicAuth
func SetBasicAuth(username, password string) ClientOptionFunc { return func(c *Client) error { c.basicAuthUsername = username c.basicAuthPassword = password c.basicAuth = c.basicAuthUsername != "" || c.basicAuthPassword != "" return nil } }
go
func SetBasicAuth(username, password string) ClientOptionFunc { return func(c *Client) error { c.basicAuthUsername = username c.basicAuthPassword = password c.basicAuth = c.basicAuthUsername != "" || c.basicAuthPassword != "" return nil } }
[ "func", "SetBasicAuth", "(", "username", ",", "password", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "c", ".", "basicAuthUsername", "=", "username", "\n", "c", ".", "basicAuthPassword", "=", "password", "\n", "c", ".", "basicAuth", "=", "c", ".", "basicAuthUsername", "!=", "\"", "\"", "||", "c", ".", "basicAuthPassword", "!=", "\"", "\"", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetBasicAuth can be used to specify the HTTP Basic Auth credentials to // use when making HTTP requests to Elasticsearch.
[ "SetBasicAuth", "can", "be", "used", "to", "specify", "the", "HTTP", "Basic", "Auth", "credentials", "to", "use", "when", "making", "HTTP", "requests", "to", "Elasticsearch", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L479-L486
train
olivere/elastic
client.go
SetURL
func SetURL(urls ...string) ClientOptionFunc { return func(c *Client) error { switch len(urls) { case 0: c.urls = []string{DefaultURL} default: c.urls = urls } return nil } }
go
func SetURL(urls ...string) ClientOptionFunc { return func(c *Client) error { switch len(urls) { case 0: c.urls = []string{DefaultURL} default: c.urls = urls } return nil } }
[ "func", "SetURL", "(", "urls", "...", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "switch", "len", "(", "urls", ")", "{", "case", "0", ":", "c", ".", "urls", "=", "[", "]", "string", "{", "DefaultURL", "}", "\n", "default", ":", "c", ".", "urls", "=", "urls", "\n", "}", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetURL defines the URL endpoints of the Elasticsearch nodes. Notice that // when sniffing is enabled, these URLs are used to initially sniff the // cluster on startup.
[ "SetURL", "defines", "the", "URL", "endpoints", "of", "the", "Elasticsearch", "nodes", ".", "Notice", "that", "when", "sniffing", "is", "enabled", "these", "URLs", "are", "used", "to", "initially", "sniff", "the", "cluster", "on", "startup", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L491-L501
train
olivere/elastic
client.go
SetSnifferTimeoutStartup
func SetSnifferTimeoutStartup(timeout time.Duration) ClientOptionFunc { return func(c *Client) error { c.snifferTimeoutStartup = timeout return nil } }
go
func SetSnifferTimeoutStartup(timeout time.Duration) ClientOptionFunc { return func(c *Client) error { c.snifferTimeoutStartup = timeout return nil } }
[ "func", "SetSnifferTimeoutStartup", "(", "timeout", "time", ".", "Duration", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "c", ".", "snifferTimeoutStartup", "=", "timeout", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetSnifferTimeoutStartup sets the timeout for the sniffer that is used // when creating a new client. The default is 5 seconds. Notice that the // timeout being used for subsequent sniffing processes is set with // SetSnifferTimeout.
[ "SetSnifferTimeoutStartup", "sets", "the", "timeout", "for", "the", "sniffer", "that", "is", "used", "when", "creating", "a", "new", "client", ".", "The", "default", "is", "5", "seconds", ".", "Notice", "that", "the", "timeout", "being", "used", "for", "subsequent", "sniffing", "processes", "is", "set", "with", "SetSnifferTimeout", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L524-L529
train
olivere/elastic
client.go
SetSnifferTimeout
func SetSnifferTimeout(timeout time.Duration) ClientOptionFunc { return func(c *Client) error { c.snifferTimeout = timeout return nil } }
go
func SetSnifferTimeout(timeout time.Duration) ClientOptionFunc { return func(c *Client) error { c.snifferTimeout = timeout return nil } }
[ "func", "SetSnifferTimeout", "(", "timeout", "time", ".", "Duration", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "c", ".", "snifferTimeout", "=", "timeout", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetSnifferTimeout sets the timeout for the sniffer that finds the // nodes in a cluster. The default is 2 seconds. Notice that the timeout // used when creating a new client on startup is usually greater and can // be set with SetSnifferTimeoutStartup.
[ "SetSnifferTimeout", "sets", "the", "timeout", "for", "the", "sniffer", "that", "finds", "the", "nodes", "in", "a", "cluster", ".", "The", "default", "is", "2", "seconds", ".", "Notice", "that", "the", "timeout", "used", "when", "creating", "a", "new", "client", "on", "startup", "is", "usually", "greater", "and", "can", "be", "set", "with", "SetSnifferTimeoutStartup", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L535-L540
train
olivere/elastic
client.go
SetSnifferInterval
func SetSnifferInterval(interval time.Duration) ClientOptionFunc { return func(c *Client) error { c.snifferInterval = interval return nil } }
go
func SetSnifferInterval(interval time.Duration) ClientOptionFunc { return func(c *Client) error { c.snifferInterval = interval return nil } }
[ "func", "SetSnifferInterval", "(", "interval", "time", ".", "Duration", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "c", ".", "snifferInterval", "=", "interval", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetSnifferInterval sets the interval between two sniffing processes. // The default interval is 15 minutes.
[ "SetSnifferInterval", "sets", "the", "interval", "between", "two", "sniffing", "processes", ".", "The", "default", "interval", "is", "15", "minutes", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L544-L549
train
olivere/elastic
client.go
SetHealthcheckInterval
func SetHealthcheckInterval(interval time.Duration) ClientOptionFunc { return func(c *Client) error { c.healthcheckInterval = interval return nil } }
go
func SetHealthcheckInterval(interval time.Duration) ClientOptionFunc { return func(c *Client) error { c.healthcheckInterval = interval return nil } }
[ "func", "SetHealthcheckInterval", "(", "interval", "time", ".", "Duration", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "c", ".", "healthcheckInterval", "=", "interval", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetHealthcheckInterval sets the interval between two health checks. // The default interval is 60 seconds.
[ "SetHealthcheckInterval", "sets", "the", "interval", "between", "two", "health", "checks", ".", "The", "default", "interval", "is", "60", "seconds", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L605-L610
train
olivere/elastic
client.go
SetDecoder
func SetDecoder(decoder Decoder) ClientOptionFunc { return func(c *Client) error { if decoder != nil { c.decoder = decoder } else { c.decoder = &DefaultDecoder{} } return nil } }
go
func SetDecoder(decoder Decoder) ClientOptionFunc { return func(c *Client) error { if decoder != nil { c.decoder = decoder } else { c.decoder = &DefaultDecoder{} } return nil } }
[ "func", "SetDecoder", "(", "decoder", "Decoder", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "if", "decoder", "!=", "nil", "{", "c", ".", "decoder", "=", "decoder", "\n", "}", "else", "{", "c", ".", "decoder", "=", "&", "DefaultDecoder", "{", "}", "\n", "}", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetDecoder sets the Decoder to use when decoding data from Elasticsearch. // DefaultDecoder is used by default.
[ "SetDecoder", "sets", "the", "Decoder", "to", "use", "when", "decoding", "data", "from", "Elasticsearch", ".", "DefaultDecoder", "is", "used", "by", "default", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L646-L655
train
olivere/elastic
client.go
SetRequiredPlugins
func SetRequiredPlugins(plugins ...string) ClientOptionFunc { return func(c *Client) error { if c.requiredPlugins == nil { c.requiredPlugins = make([]string, 0) } c.requiredPlugins = append(c.requiredPlugins, plugins...) return nil } }
go
func SetRequiredPlugins(plugins ...string) ClientOptionFunc { return func(c *Client) error { if c.requiredPlugins == nil { c.requiredPlugins = make([]string, 0) } c.requiredPlugins = append(c.requiredPlugins, plugins...) return nil } }
[ "func", "SetRequiredPlugins", "(", "plugins", "...", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "if", "c", ".", "requiredPlugins", "==", "nil", "{", "c", ".", "requiredPlugins", "=", "make", "(", "[", "]", "string", ",", "0", ")", "\n", "}", "\n", "c", ".", "requiredPlugins", "=", "append", "(", "c", ".", "requiredPlugins", ",", "plugins", "...", ")", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetRequiredPlugins can be used to indicate that some plugins are required // before a Client will be created.
[ "SetRequiredPlugins", "can", "be", "used", "to", "indicate", "that", "some", "plugins", "are", "required", "before", "a", "Client", "will", "be", "created", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L659-L667
train
olivere/elastic
client.go
SetSendGetBodyAs
func SetSendGetBodyAs(httpMethod string) ClientOptionFunc { return func(c *Client) error { c.sendGetBodyAs = httpMethod return nil } }
go
func SetSendGetBodyAs(httpMethod string) ClientOptionFunc { return func(c *Client) error { c.sendGetBodyAs = httpMethod return nil } }
[ "func", "SetSendGetBodyAs", "(", "httpMethod", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "c", ".", "sendGetBodyAs", "=", "httpMethod", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetSendGetBodyAs specifies the HTTP method to use when sending a GET request // with a body. It is GET by default.
[ "SetSendGetBodyAs", "specifies", "the", "HTTP", "method", "to", "use", "when", "sending", "a", "GET", "request", "with", "a", "body", ".", "It", "is", "GET", "by", "default", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L698-L703
train
olivere/elastic
client.go
String
func (c *Client) String() string { c.connsMu.Lock() conns := c.conns c.connsMu.Unlock() var buf bytes.Buffer for i, conn := range conns { if i > 0 { buf.WriteString(", ") } buf.WriteString(conn.String()) } return buf.String() }
go
func (c *Client) String() string { c.connsMu.Lock() conns := c.conns c.connsMu.Unlock() var buf bytes.Buffer for i, conn := range conns { if i > 0 { buf.WriteString(", ") } buf.WriteString(conn.String()) } return buf.String() }
[ "func", "(", "c", "*", "Client", ")", "String", "(", ")", "string", "{", "c", ".", "connsMu", ".", "Lock", "(", ")", "\n", "conns", ":=", "c", ".", "conns", "\n", "c", ".", "connsMu", ".", "Unlock", "(", ")", "\n\n", "var", "buf", "bytes", ".", "Buffer", "\n", "for", "i", ",", "conn", ":=", "range", "conns", "{", "if", "i", ">", "0", "{", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "}", "\n", "buf", ".", "WriteString", "(", "conn", ".", "String", "(", ")", ")", "\n", "}", "\n", "return", "buf", ".", "String", "(", ")", "\n", "}" ]
// String returns a string representation of the client status.
[ "String", "returns", "a", "string", "representation", "of", "the", "client", "status", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L718-L731
train
olivere/elastic
client.go
IsRunning
func (c *Client) IsRunning() bool { c.mu.RLock() defer c.mu.RUnlock() return c.running }
go
func (c *Client) IsRunning() bool { c.mu.RLock() defer c.mu.RUnlock() return c.running }
[ "func", "(", "c", "*", "Client", ")", "IsRunning", "(", ")", "bool", "{", "c", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "c", ".", "running", "\n", "}" ]
// IsRunning returns true if the background processes of the client are // running, false otherwise.
[ "IsRunning", "returns", "true", "if", "the", "background", "processes", "of", "the", "client", "are", "running", "false", "otherwise", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L735-L739
train
olivere/elastic
client.go
Start
func (c *Client) Start() { c.mu.RLock() if c.running { c.mu.RUnlock() return } c.mu.RUnlock() if c.snifferEnabled { go c.sniffer() } if c.healthcheckEnabled { go c.healthchecker() } c.mu.Lock() c.running = true c.mu.Unlock() c.infof("elastic: client started") }
go
func (c *Client) Start() { c.mu.RLock() if c.running { c.mu.RUnlock() return } c.mu.RUnlock() if c.snifferEnabled { go c.sniffer() } if c.healthcheckEnabled { go c.healthchecker() } c.mu.Lock() c.running = true c.mu.Unlock() c.infof("elastic: client started") }
[ "func", "(", "c", "*", "Client", ")", "Start", "(", ")", "{", "c", ".", "mu", ".", "RLock", "(", ")", "\n", "if", "c", ".", "running", "{", "c", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "\n", "}", "\n", "c", ".", "mu", ".", "RUnlock", "(", ")", "\n\n", "if", "c", ".", "snifferEnabled", "{", "go", "c", ".", "sniffer", "(", ")", "\n", "}", "\n", "if", "c", ".", "healthcheckEnabled", "{", "go", "c", ".", "healthchecker", "(", ")", "\n", "}", "\n\n", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "c", ".", "running", "=", "true", "\n", "c", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "c", ".", "infof", "(", "\"", "\"", ")", "\n", "}" ]
// Start starts the background processes like sniffing the cluster and // periodic health checks. You don't need to run Start when creating a // client with NewClient; the background processes are run by default. // // If the background processes are already running, this is a no-op.
[ "Start", "starts", "the", "background", "processes", "like", "sniffing", "the", "cluster", "and", "periodic", "health", "checks", ".", "You", "don", "t", "need", "to", "run", "Start", "when", "creating", "a", "client", "with", "NewClient", ";", "the", "background", "processes", "are", "run", "by", "default", ".", "If", "the", "background", "processes", "are", "already", "running", "this", "is", "a", "no", "-", "op", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L746-L766
train
olivere/elastic
client.go
Stop
func (c *Client) Stop() { c.mu.RLock() if !c.running { c.mu.RUnlock() return } c.mu.RUnlock() if c.healthcheckEnabled { c.healthcheckStop <- true <-c.healthcheckStop } if c.snifferEnabled { c.snifferStop <- true <-c.snifferStop } c.mu.Lock() c.running = false c.mu.Unlock() c.infof("elastic: client stopped") }
go
func (c *Client) Stop() { c.mu.RLock() if !c.running { c.mu.RUnlock() return } c.mu.RUnlock() if c.healthcheckEnabled { c.healthcheckStop <- true <-c.healthcheckStop } if c.snifferEnabled { c.snifferStop <- true <-c.snifferStop } c.mu.Lock() c.running = false c.mu.Unlock() c.infof("elastic: client stopped") }
[ "func", "(", "c", "*", "Client", ")", "Stop", "(", ")", "{", "c", ".", "mu", ".", "RLock", "(", ")", "\n", "if", "!", "c", ".", "running", "{", "c", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "\n", "}", "\n", "c", ".", "mu", ".", "RUnlock", "(", ")", "\n\n", "if", "c", ".", "healthcheckEnabled", "{", "c", ".", "healthcheckStop", "<-", "true", "\n", "<-", "c", ".", "healthcheckStop", "\n", "}", "\n\n", "if", "c", ".", "snifferEnabled", "{", "c", ".", "snifferStop", "<-", "true", "\n", "<-", "c", ".", "snifferStop", "\n", "}", "\n\n", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "c", ".", "running", "=", "false", "\n", "c", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "c", ".", "infof", "(", "\"", "\"", ")", "\n", "}" ]
// Stop stops the background processes that the client is running, // i.e. sniffing the cluster periodically and running health checks // on the nodes. // // If the background processes are not running, this is a no-op.
[ "Stop", "stops", "the", "background", "processes", "that", "the", "client", "is", "running", "i", ".", "e", ".", "sniffing", "the", "cluster", "periodically", "and", "running", "health", "checks", "on", "the", "nodes", ".", "If", "the", "background", "processes", "are", "not", "running", "this", "is", "a", "no", "-", "op", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L773-L796
train
olivere/elastic
client.go
errorf
func (c *Client) errorf(format string, args ...interface{}) { if c.errorlog != nil { c.errorlog.Printf(format, args...) } }
go
func (c *Client) errorf(format string, args ...interface{}) { if c.errorlog != nil { c.errorlog.Printf(format, args...) } }
[ "func", "(", "c", "*", "Client", ")", "errorf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "c", ".", "errorlog", "!=", "nil", "{", "c", ".", "errorlog", ".", "Printf", "(", "format", ",", "args", "...", ")", "\n", "}", "\n", "}" ]
// errorf logs to the error log.
[ "errorf", "logs", "to", "the", "error", "log", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L799-L803
train
olivere/elastic
client.go
infof
func (c *Client) infof(format string, args ...interface{}) { if c.infolog != nil { c.infolog.Printf(format, args...) } }
go
func (c *Client) infof(format string, args ...interface{}) { if c.infolog != nil { c.infolog.Printf(format, args...) } }
[ "func", "(", "c", "*", "Client", ")", "infof", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "c", ".", "infolog", "!=", "nil", "{", "c", ".", "infolog", ".", "Printf", "(", "format", ",", "args", "...", ")", "\n", "}", "\n", "}" ]
// infof logs informational messages.
[ "infof", "logs", "informational", "messages", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L806-L810
train
olivere/elastic
client.go
tracef
func (c *Client) tracef(format string, args ...interface{}) { if c.tracelog != nil { c.tracelog.Printf(format, args...) } }
go
func (c *Client) tracef(format string, args ...interface{}) { if c.tracelog != nil { c.tracelog.Printf(format, args...) } }
[ "func", "(", "c", "*", "Client", ")", "tracef", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "c", ".", "tracelog", "!=", "nil", "{", "c", ".", "tracelog", ".", "Printf", "(", "format", ",", "args", "...", ")", "\n", "}", "\n", "}" ]
// tracef logs to the trace log.
[ "tracef", "logs", "to", "the", "trace", "log", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L813-L817
train
olivere/elastic
client.go
dumpRequest
func (c *Client) dumpRequest(r *http.Request) { if c.tracelog != nil { out, err := httputil.DumpRequestOut(r, true) if err == nil { c.tracef("%s\n", string(out)) } } }
go
func (c *Client) dumpRequest(r *http.Request) { if c.tracelog != nil { out, err := httputil.DumpRequestOut(r, true) if err == nil { c.tracef("%s\n", string(out)) } } }
[ "func", "(", "c", "*", "Client", ")", "dumpRequest", "(", "r", "*", "http", ".", "Request", ")", "{", "if", "c", ".", "tracelog", "!=", "nil", "{", "out", ",", "err", ":=", "httputil", ".", "DumpRequestOut", "(", "r", ",", "true", ")", "\n", "if", "err", "==", "nil", "{", "c", ".", "tracef", "(", "\"", "\\n", "\"", ",", "string", "(", "out", ")", ")", "\n", "}", "\n", "}", "\n", "}" ]
// dumpRequest dumps the given HTTP request to the trace log.
[ "dumpRequest", "dumps", "the", "given", "HTTP", "request", "to", "the", "trace", "log", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L820-L827
train
olivere/elastic
client.go
dumpResponse
func (c *Client) dumpResponse(resp *http.Response) { if c.tracelog != nil { out, err := httputil.DumpResponse(resp, true) if err == nil { c.tracef("%s\n", string(out)) } } }
go
func (c *Client) dumpResponse(resp *http.Response) { if c.tracelog != nil { out, err := httputil.DumpResponse(resp, true) if err == nil { c.tracef("%s\n", string(out)) } } }
[ "func", "(", "c", "*", "Client", ")", "dumpResponse", "(", "resp", "*", "http", ".", "Response", ")", "{", "if", "c", ".", "tracelog", "!=", "nil", "{", "out", ",", "err", ":=", "httputil", ".", "DumpResponse", "(", "resp", ",", "true", ")", "\n", "if", "err", "==", "nil", "{", "c", ".", "tracef", "(", "\"", "\\n", "\"", ",", "string", "(", "out", ")", ")", "\n", "}", "\n", "}", "\n", "}" ]
// dumpResponse dumps the given HTTP response to the trace log.
[ "dumpResponse", "dumps", "the", "given", "HTTP", "response", "to", "the", "trace", "log", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L830-L837
train
olivere/elastic
client.go
healthcheck
func (c *Client) healthcheck(parentCtx context.Context, timeout time.Duration, force bool) { c.mu.RLock() if !c.healthcheckEnabled && !force { c.mu.RUnlock() return } basicAuth := c.basicAuth basicAuthUsername := c.basicAuthUsername basicAuthPassword := c.basicAuthPassword c.mu.RUnlock() c.connsMu.RLock() conns := c.conns c.connsMu.RUnlock() for _, conn := range conns { // Run the HEAD request against ES with a timeout ctx, cancel := context.WithTimeout(parentCtx, timeout) defer cancel() // Goroutine executes the HTTP request, returns an error and sets status var status int errc := make(chan error, 1) go func(url string) { req, err := NewRequest("HEAD", url) if err != nil { errc <- err return } if basicAuth { req.SetBasicAuth(basicAuthUsername, basicAuthPassword) } res, err := c.c.Do((*http.Request)(req).WithContext(ctx)) if res != nil { status = res.StatusCode if res.Body != nil { res.Body.Close() } } errc <- err }(conn.URL()) // Wait for the Goroutine (or its timeout) select { case <-ctx.Done(): // timeout c.errorf("elastic: %s is dead", conn.URL()) conn.MarkAsDead() case err := <-errc: if err != nil { c.errorf("elastic: %s is dead", conn.URL()) conn.MarkAsDead() break } if status >= 200 && status < 300 { conn.MarkAsAlive() } else { conn.MarkAsDead() c.errorf("elastic: %s is dead [status=%d]", conn.URL(), status) } } } }
go
func (c *Client) healthcheck(parentCtx context.Context, timeout time.Duration, force bool) { c.mu.RLock() if !c.healthcheckEnabled && !force { c.mu.RUnlock() return } basicAuth := c.basicAuth basicAuthUsername := c.basicAuthUsername basicAuthPassword := c.basicAuthPassword c.mu.RUnlock() c.connsMu.RLock() conns := c.conns c.connsMu.RUnlock() for _, conn := range conns { // Run the HEAD request against ES with a timeout ctx, cancel := context.WithTimeout(parentCtx, timeout) defer cancel() // Goroutine executes the HTTP request, returns an error and sets status var status int errc := make(chan error, 1) go func(url string) { req, err := NewRequest("HEAD", url) if err != nil { errc <- err return } if basicAuth { req.SetBasicAuth(basicAuthUsername, basicAuthPassword) } res, err := c.c.Do((*http.Request)(req).WithContext(ctx)) if res != nil { status = res.StatusCode if res.Body != nil { res.Body.Close() } } errc <- err }(conn.URL()) // Wait for the Goroutine (or its timeout) select { case <-ctx.Done(): // timeout c.errorf("elastic: %s is dead", conn.URL()) conn.MarkAsDead() case err := <-errc: if err != nil { c.errorf("elastic: %s is dead", conn.URL()) conn.MarkAsDead() break } if status >= 200 && status < 300 { conn.MarkAsAlive() } else { conn.MarkAsDead() c.errorf("elastic: %s is dead [status=%d]", conn.URL(), status) } } } }
[ "func", "(", "c", "*", "Client", ")", "healthcheck", "(", "parentCtx", "context", ".", "Context", ",", "timeout", "time", ".", "Duration", ",", "force", "bool", ")", "{", "c", ".", "mu", ".", "RLock", "(", ")", "\n", "if", "!", "c", ".", "healthcheckEnabled", "&&", "!", "force", "{", "c", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "\n", "}", "\n", "basicAuth", ":=", "c", ".", "basicAuth", "\n", "basicAuthUsername", ":=", "c", ".", "basicAuthUsername", "\n", "basicAuthPassword", ":=", "c", ".", "basicAuthPassword", "\n", "c", ".", "mu", ".", "RUnlock", "(", ")", "\n\n", "c", ".", "connsMu", ".", "RLock", "(", ")", "\n", "conns", ":=", "c", ".", "conns", "\n", "c", ".", "connsMu", ".", "RUnlock", "(", ")", "\n\n", "for", "_", ",", "conn", ":=", "range", "conns", "{", "// Run the HEAD request against ES with a timeout", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "parentCtx", ",", "timeout", ")", "\n", "defer", "cancel", "(", ")", "\n\n", "// Goroutine executes the HTTP request, returns an error and sets status", "var", "status", "int", "\n", "errc", ":=", "make", "(", "chan", "error", ",", "1", ")", "\n", "go", "func", "(", "url", "string", ")", "{", "req", ",", "err", ":=", "NewRequest", "(", "\"", "\"", ",", "url", ")", "\n", "if", "err", "!=", "nil", "{", "errc", "<-", "err", "\n", "return", "\n", "}", "\n", "if", "basicAuth", "{", "req", ".", "SetBasicAuth", "(", "basicAuthUsername", ",", "basicAuthPassword", ")", "\n", "}", "\n", "res", ",", "err", ":=", "c", ".", "c", ".", "Do", "(", "(", "*", "http", ".", "Request", ")", "(", "req", ")", ".", "WithContext", "(", "ctx", ")", ")", "\n", "if", "res", "!=", "nil", "{", "status", "=", "res", ".", "StatusCode", "\n", "if", "res", ".", "Body", "!=", "nil", "{", "res", ".", "Body", ".", "Close", "(", ")", "\n", "}", "\n", "}", "\n", "errc", "<-", "err", "\n", "}", "(", "conn", ".", "URL", "(", ")", ")", "\n\n", "// Wait for the Goroutine (or its timeout)", "select", "{", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "// timeout", "c", ".", "errorf", "(", "\"", "\"", ",", "conn", ".", "URL", "(", ")", ")", "\n", "conn", ".", "MarkAsDead", "(", ")", "\n", "case", "err", ":=", "<-", "errc", ":", "if", "err", "!=", "nil", "{", "c", ".", "errorf", "(", "\"", "\"", ",", "conn", ".", "URL", "(", ")", ")", "\n", "conn", ".", "MarkAsDead", "(", ")", "\n", "break", "\n", "}", "\n", "if", "status", ">=", "200", "&&", "status", "<", "300", "{", "conn", ".", "MarkAsAlive", "(", ")", "\n", "}", "else", "{", "conn", ".", "MarkAsDead", "(", ")", "\n", "c", ".", "errorf", "(", "\"", "\"", ",", "conn", ".", "URL", "(", ")", ",", "status", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}" ]
// healthcheck does a health check on all nodes in the cluster. Depending on // the node state, it marks connections as dead, sets them alive etc. // If healthchecks are disabled and force is false, this is a no-op. // The timeout specifies how long to wait for a response from Elasticsearch.
[ "healthcheck", "does", "a", "health", "check", "on", "all", "nodes", "in", "the", "cluster", ".", "Depending", "on", "the", "node", "state", "it", "marks", "connections", "as", "dead", "sets", "them", "alive", "etc", ".", "If", "healthchecks", "are", "disabled", "and", "force", "is", "false", "this", "is", "a", "no", "-", "op", ".", "The", "timeout", "specifies", "how", "long", "to", "wait", "for", "a", "response", "from", "Elasticsearch", "." ]
0534a7b1bf47b1ccf57e905491a641709f8a623d
https://github.com/olivere/elastic/blob/0534a7b1bf47b1ccf57e905491a641709f8a623d/client.go#L1059-L1120
train