Skip to content

Commit f302f93

Browse files
committed
docs: add truncate, batch describe, alter properties, and collection functions
Signed-off-by: ryjiang <jiangruiyi@gmail.com>
1 parent 888d2e8 commit f302f93

1 file changed

Lines changed: 107 additions & 0 deletions

File tree

docs/content/management/collection-management.mdx

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,113 @@ await client.dropCollection({
430430
5. **Compaction**: Regularly compact collections to optimize performance
431431
6. **Release**: Release collections from memory when not in use to free resources
432432

433+
## Truncate Collection
434+
435+
Remove all data from a collection while keeping its schema and indexes:
436+
437+
```javascript
438+
await client.truncateCollection({
439+
collection_name: 'my_collection',
440+
});
441+
```
442+
443+
This is faster than dropping and recreating the collection when you only need to clear data.
444+
445+
## Batch Describe Collections
446+
447+
Describe multiple collections in a single call:
448+
449+
```javascript
450+
const result = await client.batchDescribeCollections({
451+
collection_names: ['collection_a', 'collection_b', 'collection_c'],
452+
});
453+
454+
result.responses.forEach(col => {
455+
console.log(`Collection: ${col.collectionName}`);
456+
console.log(`Fields: ${col.schema.fields.map(f => f.name)}`);
457+
});
458+
```
459+
460+
## Alter Collection Properties
461+
462+
Modify collection-level properties:
463+
464+
```javascript
465+
await client.alterCollectionProperties({
466+
collection_name: 'my_collection',
467+
properties: {
468+
'collection.ttl.seconds': 7200,
469+
},
470+
});
471+
```
472+
473+
### Alter Field Properties
474+
475+
Modify field-level properties:
476+
477+
```javascript
478+
await client.alterCollectionFieldProperties({
479+
collection_name: 'my_collection',
480+
field_name: 'text',
481+
properties: {
482+
max_length: 1024,
483+
},
484+
});
485+
```
486+
487+
### Drop Collection Properties
488+
489+
Remove collection properties:
490+
491+
```javascript
492+
await client.dropCollectionProperties({
493+
collection_name: 'my_collection',
494+
properties: ['collection.ttl.seconds'],
495+
});
496+
```
497+
498+
## Collection Functions
499+
500+
Collection functions are auto-processing pipelines that transform data at insert and query time. The most common use case is BM25 full-text search, where a function automatically converts text to sparse vectors.
501+
502+
### Add a Function
503+
504+
```javascript
505+
import { FunctionType } from '@zilliz/milvus2-sdk-node';
506+
507+
await client.addCollectionFunction({
508+
collection_name: 'my_collection',
509+
function: {
510+
name: 'text_bm25',
511+
type: FunctionType.BM25,
512+
input_field_names: ['body'],
513+
output_field_names: ['sparse_vector'],
514+
params: {},
515+
},
516+
});
517+
```
518+
519+
### Drop a Function
520+
521+
```javascript
522+
await client.dropCollectionFunction({
523+
collection_name: 'my_collection',
524+
function_name: 'text_bm25',
525+
});
526+
```
527+
528+
For more details on BM25 functions, see [Full-Text Search](/advanced/full-text-search).
529+
530+
## Refresh Load
531+
532+
After modifying a loaded collection's schema (e.g., adding fields or functions), refresh the load to pick up changes:
533+
534+
```javascript
535+
await client.refreshLoad({
536+
collection_name: 'my_collection',
537+
});
538+
```
539+
433540
## Next Steps
434541

435542
- Learn about [Partition Management](./partition-management)

0 commit comments

Comments
 (0)