Skip to content

Commit

Permalink
add bulk es
Browse files Browse the repository at this point in the history
  • Loading branch information
gr4c2-2000 committed May 28, 2024
1 parent b6f9a7b commit c0c3029
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/elasticsearch/elasticsearch5.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (e *ElasticSearchGatway5) BulkIndexDocuments(ctx context.Context, index str

for _, doc := range documents {
// Meta line for each bulk operation
meta := []byte(fmt.Sprintf(`{ "index" : { "_index": "%s", "_type": "%s", "_id": "%s" } }%s`, index, docType, doc["id"], "\n"))
meta := []byte(fmt.Sprintf(`{ "index" : { "_index": "%s", "_type": "%s", "_id": "%v" } }%s`, index, docType, doc["id"], "\n"))
buf.Write(meta)

// Document data
Expand Down
2 changes: 1 addition & 1 deletion pkg/elasticsearch/elasticsearch8.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (e *ElasticSearchGatway8) Create(ctx context.Context, index string, docType
func (e *ElasticSearchGatway8) BulkIndexDocuments(ctx context.Context, index string, docType string, documents []map[string]interface{}) error {
var buf bytes.Buffer
for _, doc := range documents {
meta := []byte(fmt.Sprintf(`{ "index" : { "_id" : "%s" } }%s`, doc["id"], "\n"))
meta := []byte(fmt.Sprintf(`{ "index" : { "_id" : "%v" } }%s`, doc["id"], "\n"))
data, err := json.Marshal(doc)
if err != nil {
return err
Expand Down

0 comments on commit c0c3029

Please sign in to comment.