MCPcopy
hub / github.com/elastic/go-elasticsearch / Do

Method Do

esapi/api.bulk.go:85–241  ·  view source on GitHub ↗

Do executes the request and returns response or error.

(providedCtx context.Context, transport Transport)

Source from the content-addressed store, hash-verified

83
84// Do executes the request and returns response or error.
85func (r BulkRequest) Do(providedCtx context.Context, transport Transport) (*Response, error) {
86 var (
87 method string
88 path strings.Builder
89 params map[string]string
90 ctx context.Context
91 )
92
93 if instrument, ok := r.Instrument.(Instrumentation); ok {
94 ctx = instrument.Start(providedCtx, "bulk")
95 defer instrument.Close(ctx)
96 }
97 if ctx == nil {
98 ctx = providedCtx
99 }
100
101 method = "POST"
102
103 path.Grow(7 + 1 + len(r.Index) + 1 + len("_bulk"))
104 path.WriteString("http://")
105 if r.Index != "" {
106 path.WriteString("/")
107 path.WriteString(r.Index)
108 if instrument, ok := r.Instrument.(Instrumentation); ok {
109 instrument.RecordPathPart(ctx, "index", r.Index)
110 }
111 }
112 path.WriteString("/")
113 path.WriteString("_bulk")
114
115 params = make(map[string]string)
116
117 if r.IncludeSourceOnError != nil {
118 params["include_source_on_error"] = strconv.FormatBool(*r.IncludeSourceOnError)
119 }
120
121 if r.ListExecutedPipelines != nil {
122 params["list_executed_pipelines"] = strconv.FormatBool(*r.ListExecutedPipelines)
123 }
124
125 if r.Pipeline != "" {
126 params["pipeline"] = r.Pipeline
127 }
128
129 if r.Refresh != "" {
130 params["refresh"] = r.Refresh
131 }
132
133 if r.RequireAlias != nil {
134 params["require_alias"] = strconv.FormatBool(*r.RequireAlias)
135 }
136
137 if r.RequireDataStream != nil {
138 params["require_data_stream"] = strconv.FormatBool(*r.RequireDataStream)
139 }
140
141 if len(r.Routing) > 0 {
142 params["routing"] = strings.Join(r.Routing, ",")

Callers 2

BenchmarkClientAPIFunction · 0.95
flushBufferMethod · 0.95

Calls 15

formatDurationFunction · 0.85
newRequestFunction · 0.85
JoinMethod · 0.80
CloseMethod · 0.65
AddMethod · 0.65
PerformMethod · 0.65
StartMethod · 0.45
RecordPathPartMethod · 0.45
StringMethod · 0.45
RecordErrorMethod · 0.45
QueryMethod · 0.45
SetMethod · 0.45

Tested by 1

BenchmarkClientAPIFunction · 0.76