|
|
|
|
@ -1390,8 +1390,39 @@ class Qdrant(VectorStore):
|
|
|
|
|
path=path,
|
|
|
|
|
**kwargs,
|
|
|
|
|
)
|
|
|
|
|
try:
|
|
|
|
|
# Skip any validation in case of forced collection recreate.
|
|
|
|
|
all_collection_name = []
|
|
|
|
|
collections_response = client.get_collections()
|
|
|
|
|
collection_list = collections_response.collections
|
|
|
|
|
for collection in collection_list:
|
|
|
|
|
all_collection_name.append(collection.name)
|
|
|
|
|
if collection_name not in all_collection_name:
|
|
|
|
|
vectors_config = rest.VectorParams(
|
|
|
|
|
size=vector_size,
|
|
|
|
|
distance=rest.Distance[distance_func],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# If vector name was provided, we're going to use the named vectors feature
|
|
|
|
|
# with just a single vector.
|
|
|
|
|
if vector_name is not None:
|
|
|
|
|
vectors_config = { # type: ignore[assignment]
|
|
|
|
|
vector_name: vectors_config,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client.recreate_collection(
|
|
|
|
|
collection_name=collection_name,
|
|
|
|
|
vectors_config=vectors_config,
|
|
|
|
|
shard_number=shard_number,
|
|
|
|
|
replication_factor=replication_factor,
|
|
|
|
|
write_consistency_factor=write_consistency_factor,
|
|
|
|
|
on_disk_payload=on_disk_payload,
|
|
|
|
|
hnsw_config=hnsw_config,
|
|
|
|
|
optimizers_config=optimizers_config,
|
|
|
|
|
wal_config=wal_config,
|
|
|
|
|
quantization_config=quantization_config,
|
|
|
|
|
init_from=init_from,
|
|
|
|
|
timeout=timeout, # type: ignore[arg-type]
|
|
|
|
|
)
|
|
|
|
|
is_new_collection = True
|
|
|
|
|
if force_recreate:
|
|
|
|
|
raise ValueError
|
|
|
|
|
|
|
|
|
|
@ -1453,34 +1484,6 @@ class Qdrant(VectorStore):
|
|
|
|
|
f"recreate the collection, set `force_recreate` parameter to "
|
|
|
|
|
f"`True`."
|
|
|
|
|
)
|
|
|
|
|
except (UnexpectedResponse, RpcError, ValueError):
|
|
|
|
|
vectors_config = rest.VectorParams(
|
|
|
|
|
size=vector_size,
|
|
|
|
|
distance=rest.Distance[distance_func],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# If vector name was provided, we're going to use the named vectors feature
|
|
|
|
|
# with just a single vector.
|
|
|
|
|
if vector_name is not None:
|
|
|
|
|
vectors_config = { # type: ignore[assignment]
|
|
|
|
|
vector_name: vectors_config,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client.recreate_collection(
|
|
|
|
|
collection_name=collection_name,
|
|
|
|
|
vectors_config=vectors_config,
|
|
|
|
|
shard_number=shard_number,
|
|
|
|
|
replication_factor=replication_factor,
|
|
|
|
|
write_consistency_factor=write_consistency_factor,
|
|
|
|
|
on_disk_payload=on_disk_payload,
|
|
|
|
|
hnsw_config=hnsw_config,
|
|
|
|
|
optimizers_config=optimizers_config,
|
|
|
|
|
wal_config=wal_config,
|
|
|
|
|
quantization_config=quantization_config,
|
|
|
|
|
init_from=init_from,
|
|
|
|
|
timeout=timeout, # type: ignore[arg-type]
|
|
|
|
|
)
|
|
|
|
|
is_new_collection = True
|
|
|
|
|
qdrant = cls(
|
|
|
|
|
client=client,
|
|
|
|
|
collection_name=collection_name,
|
|
|
|
|
|