Go中Elasticsearch的大量更新

I try to update my database of elasticsearch with golang.I have two functions :

func UpdateAllByUserID(client *elastic.Client, id string, requestName string, requestNick string) error {
    ctx := context.Background()

    query := elastic.NewMatchQuery("user_id", id)

    out_name, err := client.UpdateByQuery().Index("test").Type("test").Query(query).Script(elastic.NewScriptInline("ctx._source.user_name = '" + requestName + "'")).Do(ctx)
    if nil != err {
        log.Println(err)
    }

    fmt.Println("update all name: ", out_name.Updated)

    return nil

}


func UpdateAllNicksByUserIdInFeed(client *elastic.Client, id string, requestNick string) error {
    ctx := context.Background()

    query := elastic.NewMatchQuery("user_id", id)


    out_nick, err := client.UpdateByQuery().Index("test").Type("test").Query(query).Script(elastic.NewScriptInline("ctx._source.user_nick = '" + requestNick + "'")).Do(ctx)
    if nil != err {
        log.Println(err)
    }

    fmt.Println("update all nick: ", out_nick.Updated)

    return nil

}

The POST in elastic:

POST {index}/{type}/_update_by_query
{
  "script": {
    "inline": "ctx._source.user_name = 'test'",
    "inline": "ctx._source.user_nick = 'test test'"
  },
  "query": {
    "match": {
      "user_id": "mtJZngDOy6Qj22Qv9MEf1MhSLVb2"
    }
  }
}

I'm using the library github.com/olivere/elastic. The versión of elasticsearch is 5.6 This functions per separate it works well, but I have two problems:

How can update in the same function? Why then use the two functions at the same time I have this error:

elastic: Error 409 (Conflict)

I resolved the problem:

out_name, err := client.UpdateByQuery().Index("test").Type("test").Query(query).Script(elastic.NewScriptInline("ctx._source.user_name = '" + requestName + "';ctx._source.user_nick = '" + requestNick + "';ctx._source.user_photo = '" + fullImageURL + "';ctx._source.user_thumb = '" + thumbnailURL + "'")).Do(ctx)
    if nil != err {
        log.Println(err)
    }

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html

If you want to simply count version conflicts, and not cause the _update_by_query to abort, you can set conflicts=proceed on the url or "conflicts": "proceed" in the request body. The first example does this because it is just trying to pick up an online mapping change, and a version conflict simply means that the conflicting document was updated between the start of the _update_by_query and the time when it attempted to update the document. This is fine because that update will have picked up the online mapping update.

you only need to set conflicts=proceed on the url or "conflicts": "proceed" in the request body.