or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

client-setup.mdclustering-sharding.mdcollection-management.mdfastembed-integration.mdindex.mdindexing-optimization.mdsearch-query.mdsnapshots-backup.mdvector-operations.md

collection-management.mddocs/

0

# Collection Management

1

2

Collection creation, deletion, configuration, and metadata management including vector space configuration, optimization settings, and aliasing.

3

4

## Capabilities

5

6

### Collection Creation

7

8

Create collections with vector space configuration and optimization parameters.

9

10

```python { .api }

11

def create_collection(

12

self,

13

collection_name: str,

14

vectors_config: Union[VectorParams, VectorsConfig],

15

shard_number: Optional[int] = None,

16

replication_factor: Optional[int] = None,

17

write_consistency_factor: Optional[int] = None,

18

on_disk_payload: Optional[bool] = None,

19

hnsw_config: Optional[HnswConfig] = None,

20

optimizers_config: Optional[OptimizersConfig] = None,

21

wal_config: Optional[WalConfig] = None,

22

quantization_config: Optional[QuantizationConfig] = None,

23

init_from: Optional[InitFrom] = None,

24

timeout: Optional[int] = None,

25

) -> bool:

26

"""

27

Create a new collection.

28

29

Parameters:

30

- collection_name: Name of the collection

31

- vectors_config: Vector space configuration

32

- shard_number: Number of shards for collection

33

- replication_factor: Replication factor for collection

34

- write_consistency_factor: Write consistency factor

35

- on_disk_payload: Store payload on disk

36

- hnsw_config: HNSW index configuration

37

- optimizers_config: Optimization configuration

38

- wal_config: Write-ahead log configuration

39

- quantization_config: Quantization settings

40

- init_from: Initialize from existing collection

41

- timeout: Request timeout

42

43

Returns:

44

bool: True if collection created successfully

45

"""

46

```

47

48

Usage examples:

49

50

```python

51

from qdrant_client import models

52

53

# Simple vector collection

54

client.create_collection(

55

collection_name="simple_collection",

56

vectors_config=models.VectorParams(size=384, distance=models.Distance.COSINE)

57

)

58

59

# Multi-vector collection

60

client.create_collection(

61

collection_name="multi_vector_collection",

62

vectors_config={

63

"image": models.VectorParams(size=512, distance=models.Distance.COSINE),

64

"text": models.VectorParams(size=384, distance=models.Distance.COSINE)

65

}

66

)

67

68

# Advanced configuration

69

client.create_collection(

70

collection_name="optimized_collection",

71

vectors_config=models.VectorParams(size=768, distance=models.Distance.COSINE),

72

hnsw_config=models.HnswConfig(

73

m=16,

74

ef_construct=100,

75

full_scan_threshold=10000

76

),

77

quantization_config=models.ScalarQuantization(

78

scalar=models.ScalarQuantizationConfig(

79

type=models.ScalarType.INT8,

80

always_ram=True

81

)

82

)

83

)

84

```

85

86

### Collection Information

87

88

Retrieve collection metadata and statistics.

89

90

```python { .api }

91

def get_collection(self, collection_name: str) -> CollectionInfo:

92

"""

93

Get collection information.

94

95

Parameters:

96

- collection_name: Name of the collection

97

98

Returns:

99

CollectionInfo: Collection metadata and statistics

100

"""

101

102

def get_collections(self) -> CollectionsResponse:

103

"""

104

List all collections.

105

106

Returns:

107

CollectionsResponse: List of collection descriptions

108

"""

109

110

def collection_exists(self, collection_name: str) -> bool:

111

"""

112

Check if collection exists.

113

114

Parameters:

115

- collection_name: Name of collection to check

116

117

Returns:

118

bool: True if collection exists

119

"""

120

```

121

122

### Collection Updates

123

124

Modify existing collection configuration.

125

126

```python { .api }

127

def update_collection(

128

self,

129

collection_name: str,

130

optimizer_config: Optional[OptimizersConfig] = None,

131

collection_params: Optional[CollectionParams] = None,

132

timeout: Optional[int] = None,

133

**kwargs

134

) -> bool:

135

"""

136

Update collection configuration.

137

138

Parameters:

139

- collection_name: Name of the collection

140

- optimizer_config: New optimizer configuration

141

- collection_params: New collection parameters

142

- timeout: Request timeout

143

144

Returns:

145

bool: True if collection updated successfully

146

"""

147

```

148

149

### Collection Deletion

150

151

Remove collections and their data.

152

153

```python { .api }

154

def delete_collection(

155

self,

156

collection_name: str,

157

timeout: Optional[int] = None

158

) -> bool:

159

"""

160

Delete collection.

161

162

Parameters:

163

- collection_name: Name of the collection to delete

164

- timeout: Request timeout

165

166

Returns:

167

bool: True if collection deleted successfully

168

"""

169

```

170

171

### Collection Aliases

172

173

Create and manage collection aliases for flexible naming.

174

175

```python { .api }

176

def create_alias(

177

self,

178

alias_name: str,

179

collection_name: str,

180

timeout: Optional[int] = None,

181

**kwargs

182

) -> bool:

183

"""

184

Create collection alias.

185

186

Parameters:

187

- alias_name: Name of the alias

188

- collection_name: Target collection name

189

- timeout: Request timeout

190

191

Returns:

192

bool: True if alias created successfully

193

"""

194

195

def delete_alias(

196

self,

197

alias_name: str,

198

timeout: Optional[int] = None,

199

**kwargs

200

) -> bool:

201

"""

202

Delete collection alias.

203

204

Parameters:

205

- alias_name: Name of the alias to delete

206

- timeout: Request timeout

207

208

Returns:

209

bool: True if alias deleted successfully

210

"""

211

212

def get_aliases(self, **kwargs) -> AliasesResponse:

213

"""

214

List all collection aliases.

215

216

Returns:

217

AliasesResponse: List of collection aliases

218

"""

219

```

220

221

## Configuration Types

222

223

### Vector Configuration

224

225

```python { .api }

226

class VectorParams(BaseModel):

227

size: int # Vector dimension

228

distance: Distance # Distance metric

229

hnsw_config: Optional[HnswConfig] = None

230

quantization_config: Optional[QuantizationConfig] = None

231

on_disk: Optional[bool] = None # Store vectors on disk

232

233

class Distance(str, Enum):

234

COSINE = "Cosine"

235

EUCLID = "Euclid"

236

DOT = "Dot"

237

MANHATTAN = "Manhattan"

238

239

# Multi-vector configuration

240

VectorsConfig = Dict[str, VectorParams]

241

```

242

243

### HNSW Configuration

244

245

```python { .api }

246

class HnswConfig(BaseModel):

247

m: Optional[int] = None # Number of bi-directional links

248

ef_construct: Optional[int] = None # Size of dynamic candidate list

249

full_scan_threshold: Optional[int] = None # Threshold for full scan

250

max_indexing_threads: Optional[int] = None # Max indexing threads

251

on_disk: Optional[bool] = None # Store HNSW graph on disk

252

payload_m: Optional[int] = None # Number of payload-aware links

253

```

254

255

### Quantization Configuration

256

257

```python { .api }

258

class ScalarQuantization(BaseModel):

259

scalar: ScalarQuantizationConfig

260

261

class ScalarQuantizationConfig(BaseModel):

262

type: ScalarType # INT8 or UINT8

263

quantile: Optional[float] = None # Quantile for quantization

264

always_ram: Optional[bool] = None # Keep quantized vectors in RAM

265

266

class ScalarType(str, Enum):

267

INT8 = "int8"

268

UINT8 = "uint8"

269

270

class ProductQuantization(BaseModel):

271

product: ProductQuantizationConfig

272

273

class ProductQuantizationConfig(BaseModel):

274

compression: CompressionRatio # Compression ratio

275

always_ram: Optional[bool] = None

276

277

class CompressionRatio(str, Enum):

278

X4 = "x4"

279

X8 = "x8"

280

X16 = "x16"

281

X32 = "x32"

282

X64 = "x64"

283

284

class BinaryQuantization(BaseModel):

285

binary: BinaryQuantizationConfig

286

287

class BinaryQuantizationConfig(BaseModel):

288

always_ram: Optional[bool] = None

289

```

290

291

### Optimizer Configuration

292

293

```python { .api }

294

class OptimizersConfig(BaseModel):

295

deleted_threshold: Optional[float] = None # Threshold for deleted points

296

vacuum_min_vector_number: Optional[int] = None # Min vectors for vacuum

297

default_segment_number: Optional[int] = None # Default segments per shard

298

max_segment_size: Optional[int] = None # Max segment size

299

memmap_threshold: Optional[int] = None # Memory mapping threshold

300

indexing_threshold: Optional[int] = None # Indexing threshold

301

flush_interval_sec: Optional[int] = None # Flush interval in seconds

302

max_optimization_threads: Optional[int] = None # Max optimization threads

303

```

304

305

### WAL Configuration

306

307

```python { .api }

308

class WalConfig(BaseModel):

309

wal_capacity_mb: Optional[int] = None # WAL capacity in MB

310

wal_segments_ahead: Optional[int] = None # WAL segments ahead

311

```

312

313

## Collection Information Types

314

315

```python { .api }

316

class CollectionInfo(BaseModel):

317

status: CollectionStatus

318

optimizer_status: OptimizerStatus

319

vectors_count: Optional[int] = None

320

indexed_vectors_count: Optional[int] = None

321

points_count: Optional[int] = None

322

segments_count: int

323

config: CollectionConfig

324

payload_schema: Dict[str, PayloadIndexInfo]

325

326

class CollectionStatus(str, Enum):

327

GREEN = "green" # All good

328

YELLOW = "yellow" # Optimization in progress

329

RED = "red" # Some shards are not available

330

331

class CollectionConfig(BaseModel):

332

params: CollectionParams

333

hnsw_config: HnswConfig

334

optimizer_config: OptimizersConfig

335

wal_config: WalConfig

336

quantization_config: Optional[QuantizationConfig] = None

337

```