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

Function main

_examples/msearchtemplate/default.go:41–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39const demoIndex = "msearch-template-demo"
40
41func main() {
42 log.SetFlags(0)
43
44 es, err := elasticsearch.New()
45 if err != nil {
46 log.Fatalf("Error creating client: %s", err)
47 }
48 defer closeClient(es)
49
50 typed, err := elasticsearch.NewTyped()
51 if err != nil {
52 log.Fatalf("Error creating typed client: %s", err)
53 }
54 defer closeTypedClient(typed)
55
56 ctx := context.Background()
57 setupDemoData(ctx, es)
58
59 log.Println("=== MSearchTemplate using esapi (raw NDJSON) ===")
60 runEsapiExample(ctx, es)
61
62 log.Println()
63 log.Println("=== MSearchTemplate using typedapi ===")
64 runTypedAPIExample(ctx, typed)
65}
66
67func closeClient(es *elasticsearch.Client) {
68 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)

Callers

nothing calls this directly

Calls 5

closeClientFunction · 0.85
closeTypedClientFunction · 0.85
setupDemoDataFunction · 0.85
runEsapiExampleFunction · 0.85
runTypedAPIExampleFunction · 0.85

Tested by

no test coverage detected