Skip to content

Commit

Permalink
fix using routing in bulk operations (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
enesyalinkaya authored Apr 22, 2024
1 parent 15f70c7 commit f592cce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion elasticsearch/bulk/bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (b *Bulk) AddActions(
b.typeName,
)

key := getActionKey(action)
key := getActionKey(actions[i])
if batchIndex, ok := b.batchKeys[key]; ok {
b.batchByteSize += len(value) - len(b.batch[batchIndex].Bytes)
b.batch[batchIndex] = BatchItem{
Expand Down Expand Up @@ -386,6 +386,9 @@ func (b *Bulk) executeSinkResponseHandler(batchActions []*document.ESActionDocum
}

func getActionKey(action document.ESActionDocument) string {
if action.Routing != nil {
return fmt.Sprintf("%s:%s:%s", action.ID, action.IndexName, *action.Routing)
}
return fmt.Sprintf("%s:%s", action.ID, action.IndexName)
}

Expand Down

0 comments on commit f592cce

Please sign in to comment.