From b0b0ec2b58e1d726911ba334e650717230fb2e2f Mon Sep 17 00:00:00 2001 From: loveuer Date: Sun, 24 Mar 2024 20:47:54 +0800 Subject: [PATCH] wip: mapping type --- internal/xes/xes_test.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 internal/xes/xes_test.go diff --git a/internal/xes/xes_test.go b/internal/xes/xes_test.go new file mode 100644 index 0000000..32e04f8 --- /dev/null +++ b/internal/xes/xes_test.go @@ -0,0 +1,38 @@ +package xes + +import ( + "esgo2dump/internal/util" + elastic "github.com/elastic/go-elasticsearch/v7" + "testing" +) + +func TestGetESMapping(t *testing.T) { + endpoint := "http://127.0.0.1:9200" + index := "some_index" + + cli, err := elastic.NewClient(elastic.Config{ + Addresses: []string{endpoint}, + }) + if err != nil { + t.Error(1, err) + return + } + + resp, err := cli.Info(cli.Info.WithContext(util.Timeout(5))) + if err != nil { + t.Error(2, err) + return + } + + t.Log("info:", resp.String()) + + r, err := cli.Indices.GetMapping( + cli.Indices.GetMapping.WithIndex(index), + ) + if err != nil { + t.Error(3, err) + return + } + + t.Log("get source:", r.String()) +}