26 lines
425 B
Markdown
26 lines
425 B
Markdown
# elasticsearch
|
|
|
|
## goang sdk
|
|
|
|
```go
|
|
// https://github.com/elastic/go-elasticsearch
|
|
import (
|
|
github.com/elastic/go-elasticsearch/v7
|
|
)
|
|
|
|
es, err := elasticsearch.NewClient(elasticsearch.Config{})
|
|
|
|
// create document
|
|
req := esapi.IndexRequest{
|
|
Index: "sample_edge",
|
|
Body: bytes.NewReader(body),
|
|
}
|
|
res, err := req.Do(context.Background(), es)
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
```
|
|
|