【发布时间】:2022-10-07 04:09:18
【问题描述】:
我在go 中使用这个库作为 Elasticsearch 客户端:https://pkg.go.dev/github.com/elastic/go-elasticsearch/esapi#IndicesCreate.WithBody
我在用这个库创建新索引时遇到问题。文档说这种方法:
type IndicesCreate func(index string, o ...func(*IndicesCreateRequest)) (*Response, error)
这看起来像是我可以用来创建索引的那个。但我是go 的新手,不知道如何传递第二个参数。
下面是我的代码:
req := esapi.IndicesCreateRequest{
Index: indexName,
}
esapi.IndicesCreate(indexName, &req)
但我收到了too many arguments in conversion to esapi.IndicesCreate 错误消息。正确的方法是什么?
标签: go elasticsearch