Ich bin neu in Golang. Versuchen, einen Bulk-Upload nach Elasticsearch von Golang zu implementieren. Ich verwende die Golang-Bibliothek ->https://github.com/olivere/elastic für die Kommunikation mit Elasticsearch.Golang Fehler "nicht genug Argumente in Anruf"
Auch ein Stück Beispielcode, die ich versuche aber folgende Fehler bekommen ...
[email protected]:~/Desktop/tools/golang/src$ go install github.com/crazyheart/elastic-bulk-upload
# github.com/crazyheart/elastic-bulk-upload
github.com/crazyheart/elastic-bulk-upload/main.go:29: not enough arguments in call to bulkRequest.Do
have()
want ("golang.org/x/net/context".Context)
[email protected]:~/Desktop/tools/golang/src$
Mein Golang-Code (main.go)
package main
import (
"fmt"
"gopkg.in/olivere/elastic.v5"
"strconv"
)
type Tweet struct {
User string `json:"user"`
Message string `json:"message"`
}
func main() {
client, err := elastic.NewClient()
if err != nil {
fmt.Println("%v", err)
}
n := 0
for i := 0; i < 1000; i++ {
bulkRequest := client.Bulk()
for j := 0; j < 10000; j++ {
n++
tweet := Tweet{User: "olivere", Message: "Package strconv implements conversions to and from string representations of basic data types. " + strconv.Itoa(n)}
req := elastic.NewBulkIndexRequest().Index("twitter").Type("tweet").Id(strconv.Itoa(n)).Doc(tweet)
bulkRequest = bulkRequest.Add(req)
}
bulkResponse, err := bulkRequest.Do()
if err != nil {
fmt.Println(err)
}
if bulkResponse != nil {
}
fmt.Println(i)
}
}
Anybody, hilf mir zu Verstehen Sie, was dieser Fehler bedeutet &, wie Sie diese lösen?
Diese Antwort könnte helfen: http://stackoverflow.com/a/40610924/4604579 – Val
@val - Danke mir für die Unterstützung aus. – mi6crazyheart
Kein Problem, froh zu helfen! – Val