Skip to content

Commit

Permalink
milvus: add skipFlushOnWrite option (#992)
Browse files Browse the repository at this point in the history
milvus: add disableFlush option
  • Loading branch information
fatedier authored Sep 13, 2024
1 parent 47d2d99 commit 0cab9df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vectorstores/milvus/milvus.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Store struct {
metricType entity.MetricType
searchParameters entity.SearchParam
schema *entity.Schema
skipFlushOnWrite bool
}

var (
Expand Down Expand Up @@ -226,8 +227,10 @@ func (s Store) AddDocuments(ctx context.Context, docs []schema.Document,
if err != nil {
return nil, err
}
if err = s.client.Flush(ctx, s.collectionName, false); err != nil {
return nil, err
if !s.skipFlushOnWrite {
if err = s.client.Flush(ctx, s.collectionName, false); err != nil {
return nil, err
}
}
return nil, nil
}
Expand Down
7 changes: 7 additions & 0 deletions vectorstores/milvus/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ func WithMetricType(metricType entity.MetricType) Option {
}
}

// WithSkipFlushOnWrite disables flushing on write.
func WithSkipFlushOnWrite() Option {
return func(s *Store) {
s.skipFlushOnWrite = true
}
}

func applyClientOptions(opts ...Option) (Store, error) {
s := Store{
metricType: entity.L2,
Expand Down

0 comments on commit 0cab9df

Please sign in to comment.