Skip to content

Commit

Permalink
Fix for exporting all fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pteich committed Nov 1, 2021
1 parent 3245346 commit 9fb8f29
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions export.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ func export(ctx context.Context, conf *Flags) {

client, err := elastic.NewClient(esOpts...)
if err != nil {
log.Printf("Error connecting to ElasticSearch %s - %v", conf.ElasticURL, err)
os.Exit(1)
log.Fatalf("Error connecting to ElasticSearch %s - %v", conf.ElasticURL, err)
}
defer client.Stop()

Expand All @@ -51,7 +50,7 @@ func export(ctx context.Context, conf *Flags) {

outfile, err := os.Create(conf.Outfile)
if err != nil {
log.Printf("Error creating output file - %v", err)
log.Fatalf("Error creating output file - %s", err)
}
defer outfile.Close()

Expand Down Expand Up @@ -83,9 +82,11 @@ func export(ctx context.Context, conf *Flags) {
esQuery = esQuery.Must(elastic.NewMatchAllQuery())
}

source, _ := esQuery.Source()
data, _ := json.Marshal(source)
fmt.Println(string(data))
/*
source, _ := esQuery.Source()
data, _ := json.Marshal(source)
fmt.Println(string(data))
*/

// Count total and setup progress
total, err := client.Count(conf.Index).Query(esQuery).Do(ctx)
Expand Down Expand Up @@ -208,7 +209,6 @@ func export(ctx context.Context, conf *Flags) {
outdata = removeLBR(fmt.Sprintf("%v", val))
csvdata = append(csvdata, outdata)
}
continue
}

// send string array to csv output
Expand Down

0 comments on commit 9fb8f29

Please sign in to comment.