Skip to content

Commit bac7691

Browse files
authored
docs: update feature coverage for 2.6 APIs (#552)
Signed-off-by: ryjiang <jiangruiyi@gmail.com>
1 parent 1822bc9 commit bac7691

11 files changed

Lines changed: 860 additions & 116 deletions

docs/content/advanced/full-text-search.mdx

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,33 @@ console.log('Results:', result.results);
2525
// Each text input produces an AnalyzerResult with tokens
2626
```
2727

28+
You can also test analyzers that are configured on a collection field, request detailed token data, and include token hashes:
29+
30+
```javascript
31+
const result = await client.runAnalyzer({
32+
db_name: 'default',
33+
collection_name: 'articles',
34+
field_name: 'body',
35+
analyzer_names: ['english_analyzer'],
36+
text: ['Running analyzers with offsets and hashes'],
37+
with_detail: true,
38+
with_hash: true,
39+
});
40+
41+
result.results[0].tokens.forEach(token => {
42+
console.log(token.token, token.start_offset, token.end_offset, token.hash);
43+
});
44+
```
45+
46+
`runAnalyzer()` accepts either `analyzer_params` for an ad-hoc analyzer configuration or collection context fields (`db_name`, `collection_name`, `field_name`, `analyzer_names`) to use analyzers defined in a schema.
47+
2848
### Analyzer Types
2949

30-
| Type | Description |
31-
|------|-------------|
50+
| Type | Description |
51+
| ---------- | ---------------------------------------- |
3252
| `standard` | Standard tokenizer with lowercase filter |
33-
| `english` | English-specific tokenizer with stemming |
34-
| `chinese` | Chinese text tokenizer |
53+
| `english` | English-specific tokenizer with stemming |
54+
| `chinese` | Chinese text tokenizer |
3555

3656
## Creating a Full-Text Search Collection
3757

@@ -44,9 +64,24 @@ const client = new MilvusClient({ address: 'localhost:19530' });
4464
await client.createCollection({
4565
collection_name: 'articles',
4666
fields: [
47-
{ name: 'id', data_type: DataType.Int64, is_primary_key: true, autoID: true },
48-
{ name: 'title', data_type: DataType.VarChar, max_length: 256, enable_analyzer: true },
49-
{ name: 'body', data_type: DataType.VarChar, max_length: 10000, enable_analyzer: true },
67+
{
68+
name: 'id',
69+
data_type: DataType.Int64,
70+
is_primary_key: true,
71+
autoID: true,
72+
},
73+
{
74+
name: 'title',
75+
data_type: DataType.VarChar,
76+
max_length: 256,
77+
enable_analyzer: true,
78+
},
79+
{
80+
name: 'body',
81+
data_type: DataType.VarChar,
82+
max_length: 10000,
83+
enable_analyzer: true,
84+
},
5085
{ name: 'sparse_vector', data_type: DataType.SparseFloatVector },
5186
],
5287
functions: [
@@ -96,8 +131,14 @@ await client.loadCollectionSync({ collection_name: 'articles' });
96131
await client.insert({
97132
collection_name: 'articles',
98133
data: [
99-
{ title: 'Introduction to Machine Learning', body: 'Machine learning is a branch of AI...' },
100-
{ title: 'Deep Learning Basics', body: 'Deep learning uses neural networks...' },
134+
{
135+
title: 'Introduction to Machine Learning',
136+
body: 'Machine learning is a branch of AI...',
137+
},
138+
{
139+
title: 'Deep Learning Basics',
140+
body: 'Deep learning uses neural networks...',
141+
},
101142
],
102143
});
103144

@@ -129,7 +170,7 @@ const results = await client.search({
129170
limit: 10,
130171
output_fields: ['title', 'body'],
131172
highlighter: {
132-
type: 0, // HighlightType.Lexical
173+
type: 0, // HighlightType.Lexical
133174
pre_tags: ['<em>'],
134175
post_tags: ['</em>'],
135176
fragment_size: 100,
@@ -150,7 +191,7 @@ const results = await client.search({
150191
limit: 10,
151192
output_fields: ['title', 'body'],
152193
highlighter: {
153-
type: 1, // HighlightType.Semantic
194+
type: 1, // HighlightType.Semantic
154195
queries: ['machine learning'],
155196
input_fields: ['body'],
156197
pre_tags: ['<mark>'],
@@ -160,6 +201,25 @@ const results = await client.search({
160201
});
161202
```
162203

204+
### Highlight Results
205+
206+
Search hits include highlight data when highlighting is enabled. Each highlighted field contains text fragments and optional scores.
207+
208+
```javascript
209+
results.results.forEach(hit => {
210+
console.log('Title:', hit.title);
211+
console.log('Highlight:', hit.highlight);
212+
213+
const bodyHighlight = hit.highlight?.body;
214+
bodyHighlight?.fragments.forEach((fragment, index) => {
215+
console.log('Fragment:', fragment);
216+
console.log('Score:', bodyHighlight.scores?.[index]);
217+
});
218+
});
219+
```
220+
221+
For lexical highlighting, set `highlight_search_text: true` to include the matched search text in highlight output when supported by Milvus. For semantic highlighting, set `highlight_only: true` to return only highlighted fragments instead of the full source text.
222+
163223
## Managing Collection Functions
164224
165225
```javascript

docs/content/core-concepts/client-configuration.mdx

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,23 @@ const client = new MilvusClient({
6969
rootCertPath: '/path/to/ca.pem',
7070
// Or certificate buffer
7171
rootCert: Buffer.from('...'),
72-
72+
7373
// Private key path (for client authentication)
7474
privateKeyPath: '/path/to/key.pem',
7575
// Or private key buffer
7676
privateKey: Buffer.from('...'),
77-
77+
7878
// Certificate chain path
7979
certChainPath: '/path/to/cert.pem',
8080
// Or certificate buffer
8181
certChain: Buffer.from('...'),
82-
82+
8383
// Server name for SNI
8484
serverName: 'milvus.example.com',
85-
85+
8686
// Skip certificate verification (not recommended for production)
8787
skipCertCheck: false,
88-
88+
8989
// Additional verify options
9090
verifyOptions: {},
9191
},
@@ -171,6 +171,22 @@ const client = new MilvusClient({
171171
});
172172
```
173173

174+
### Connect Reserved Options
175+
176+
Use `option` to pass reserved key-value metadata in the initial Milvus `Connect` request. These values are sent as `client_info.reserved` and are useful for deployment-specific routing, attribution, or internal integrations.
177+
178+
```javascript
179+
const client = new MilvusClient({
180+
address: 'localhost:19530',
181+
option: {
182+
app: 'recommendation-service',
183+
environment: 'production',
184+
},
185+
});
186+
```
187+
188+
`option` values must be strings.
189+
174190
## Environment-Specific Configuration
175191

176192
### Development
@@ -217,32 +233,32 @@ const client = new MilvusClient({
217233
const client = new MilvusClient({
218234
// Required
219235
address: 'localhost:19530',
220-
236+
221237
// Authentication (choose one)
222238
username: 'root',
223239
password: 'Milvus',
224240
// OR
225241
token: 'api-key',
226-
242+
227243
// SSL/TLS
228244
ssl: true,
229245
tls: {
230246
rootCertPath: '/path/to/ca.pem',
231247
serverName: 'milvus.example.com',
232248
},
233-
249+
234250
// Timeouts and retries
235251
timeout: 30000,
236252
maxRetries: 3,
237253
retryDelay: 1000,
238-
254+
239255
// Database
240256
database: 'default',
241-
257+
242258
// Logging
243259
logLevel: 'info',
244260
logPrefix: 'milvus',
245-
261+
246262
// Connection pooling
247263
pool: {
248264
min: 2,
@@ -263,6 +279,7 @@ interface ClientConfig {
263279
username?: string;
264280
password?: string;
265281
channelOptions?: ChannelOptions;
282+
option?: Record<string, string>;
266283
timeout?: number | string;
267284
maxRetries?: number;
268285
retryDelay?: number;
@@ -307,6 +324,7 @@ await client.createCollection({
307324
```
308325

309326
**Features:**
327+
310328
- Automatic timestamp: Every request includes `client-request-unixmsec`
311329
- Trace ID support: Add `client_request_id` or `client-request-id` to track requests
312330
- Global support: All API methods automatically support trace IDs
@@ -319,4 +337,3 @@ For more details, see [Request Tracing](../advanced/advanced-features#request-tr
319337
- Learn about [Data Types & Schemas](./data-types-schemas)
320338
- Explore [Collection Management](./collection-management)
321339
- Check out [Best Practices](./best-practices) for production configurations
322-

docs/content/core-concepts/data-types-schemas.mdx

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,22 @@ Sparse vectors store only non-zero values with their indices. Commonly used for
144144
Sparse vectors can be inserted in two formats:
145145

146146
**Dictionary format** (recommended):
147+
147148
```javascript
148149
// Keys are indices, values are float weights
149150
{ 10: 0.5, 100: 0.3, 500: 0.8, 1200: 0.1 }
150151
```
151152

152153
**Array of tuples format:**
154+
153155
```javascript
154156
// [index, value] pairs
155-
[[10, 0.5], [100, 0.3], [500, 0.8], [1200, 0.1]]
157+
[
158+
[10, 0.5],
159+
[100, 0.3],
160+
[500, 0.8],
161+
[1200, 0.1],
162+
];
156163
```
157164

158165
Note: Dimension is determined automatically from the maximum index across all vectors.
@@ -193,6 +200,29 @@ BFloat16 vector:
193200
}
194201
```
195202

203+
#### Nullable Vector Fields
204+
205+
Vector fields can be marked as nullable. Insert or upsert `null` for rows that do not have an embedding yet; query and search results return `null` for those fields.
206+
207+
```javascript
208+
{
209+
name: 'optional_embedding',
210+
data_type: DataType.FloatVector,
211+
dim: 128,
212+
nullable: true,
213+
}
214+
215+
await client.insert({
216+
collection_name: 'my_collection',
217+
data: [
218+
{ id: 1, optional_embedding: [/* 128 floats */] },
219+
{ id: 2, optional_embedding: null },
220+
],
221+
});
222+
```
223+
224+
Nullable vector payloads are supported for `FloatVector`, `BinaryVector`, `Float16Vector`, `BFloat16Vector`, `SparseFloatVector`, and `Int8Vector`.
225+
196226
### Complex Types
197227

198228
#### Array
@@ -208,6 +238,35 @@ Array of scalar values:
208238
}
209239
```
210240

241+
#### ArrayOfVector
242+
243+
`DataType.ArrayOfVector` stores multiple vectors in a single field value. This is useful for documents split into chunks, multi-vector embeddings, or struct array payloads that contain vector arrays.
244+
245+
```javascript
246+
{
247+
name: 'chunk_embeddings',
248+
data_type: DataType.ArrayOfVector,
249+
element_type: DataType.FloatVector,
250+
dim: 128,
251+
max_capacity: 32,
252+
}
253+
254+
await client.insert({
255+
collection_name: 'my_collection',
256+
data: [
257+
{
258+
id: 1,
259+
chunk_embeddings: [
260+
[/* first 128-d vector */],
261+
[/* second 128-d vector */],
262+
],
263+
},
264+
],
265+
});
266+
```
267+
268+
Supported element vector types include dense, binary, float16, bfloat16, sparse, and int8 vector payloads where supported by Milvus.
269+
211270
#### Struct
212271

213272
Nested structure:
@@ -237,6 +296,9 @@ Each field in a collection schema must include:
237296
autoID: false, // Optional: auto-generate IDs
238297
max_length: 256, // Required for VarChar
239298
dim: 128, // Required for vector types
299+
nullable: false, // Optional: allow null values
300+
default_value: undefined, // Optional scalar default value
301+
external_field: undefined, // Optional: source field name for external collections
240302
}
241303
```
242304

@@ -364,9 +426,11 @@ await client.insert({
364426
collection_name: 'my_collection',
365427
data: [
366428
{
367-
vector: [/* ... */],
429+
vector: [
430+
/* ... */
431+
],
368432
dynamic_field_1: 'value1', // Automatically added
369-
dynamic_field_2: 123, // Automatically added
433+
dynamic_field_2: 123, // Automatically added
370434
},
371435
],
372436
});
@@ -395,4 +459,3 @@ The SDK validates schemas before creating collections. Common validation errors:
395459
- Learn about [Collection Management](./collection-management)
396460
- Explore [Data Operations](./data-operations-insert)
397461
- Check out [Best Practices](./best-practices)
398-

0 commit comments

Comments
 (0)