go-elasticsearch
go-elasticsearch copied to clipboard
WithVersion to support int 64bit instead of 32
Hey!
WithVersion
- used to explicitly set version number for concurrency control needs to support 64 bit integers instead of 32bit as currently is.
Index.WithVersion seems to get a 32bit int as input
func (f Index) WithVersion(v int) func(*IndexRequest) {
return func(r *IndexRequest) {
r.Version = &v
}
}
On the other hand the bulk api seems to support 64 bit version:
type BulkIndexerItem struct {
Index string
Action string
DocumentID string
Routing string
Version *int64
VersionType string
Body io.ReadSeeker
RetryOnConflict *int
OnSuccess func(context.Context, BulkIndexerItem, BulkIndexerResponseItem) // Per item
OnFailure func(context.Context, BulkIndexerItem, BulkIndexerResponseItem, error) // Per item
}
Hi @ani12321 "The int, uint, and uintptr types are usually 32 bits wide on 32-bit systems and 64 bits wide on 64-bit systems." (See https://go.dev/tour/basics/11). So maybe this is not a big deal to most users.
But you are right in terms of clearness and consistency that int64
is preferable over int
here. The only reason not to change it is backwards compatibility to existing code !?
as per the ES doc: Elasticsearch will work with any numerical versioning system (in the 1:2^63-1 range) Which might not be an issue in 64-bit systems, but it is an issue in 32-bit systems as we are enforcing the version to be 32-but while ES clearly can support int64