diff --git a/vectorstores/qdrant/options.go b/vectorstores/qdrant/options.go index 60c407591..ba0d5b21d 100644 --- a/vectorstores/qdrant/options.go +++ b/vectorstores/qdrant/options.go @@ -9,7 +9,8 @@ import ( ) const ( - defaultContentKey = "content" + defaultContentKey = "content" + defaultWaitForInsert = true ) // ErrInvalidOptions is returned when the options given are invalid. @@ -56,9 +57,18 @@ func WithContentKey(contentKey string) Option { } } +// WithWaitForInsert returns an Option for setting whether to wait for the insert to complete. +// Optional. Defaults to true. +func WithWaitForInsert(wait bool) Option { + return func(p *Store) { + p.waitForInsert = wait + } +} + func applyClientOptions(opts ...Option) (Store, error) { o := &Store{ - contentKey: defaultContentKey, + contentKey: defaultContentKey, + waitForInsert: defaultWaitForInsert, } for _, opt := range opts { diff --git a/vectorstores/qdrant/qdrant.go b/vectorstores/qdrant/qdrant.go index 6896c424f..e0ef186e0 100644 --- a/vectorstores/qdrant/qdrant.go +++ b/vectorstores/qdrant/qdrant.go @@ -16,6 +16,7 @@ type Store struct { qdrantURL url.URL apiKey string contentKey string + waitForInsert bool } var _ vectorstores.VectorStore = Store{} diff --git a/vectorstores/qdrant/rest.go b/vectorstores/qdrant/rest.go index e4fee5d2b..805532457 100644 --- a/vectorstores/qdrant/rest.go +++ b/vectorstores/qdrant/rest.go @@ -33,11 +33,15 @@ func (s Store) upsertPoints( }, } - url := baseURL.JoinPath("collections", s.collectionName, "points") + upsertURL := baseURL.JoinPath("collections", s.collectionName, "points") + queryParams := url.Values{} + queryParams.Add("wait", fmt.Sprintf("%t", s.waitForInsert)) + upsertURL.RawQuery = queryParams.Encode() + body, status, err := DoRequest( - ctx, *url, + ctx, *upsertURL, s.apiKey, http.MethodPut, payload, @@ -134,7 +138,7 @@ func DoRequest(ctx context.Context, } body := bytes.NewReader(payloadBytes) - req, err := http.NewRequestWithContext(ctx, method, url.String()+"?wait=true", body) + req, err := http.NewRequestWithContext(ctx, method, url.String(), body) if err != nil { return nil, 0, err }