Plan knowledge bases, manage documents, and tune retrieval. Includes a common error reference and irreversible operations checklist.
Knowledge base design
Embedding model, metadata schema, and subspace settings are immutable after creation. Plan these configurations before you begin.
Embedding model selection
The embedding model controls vector search quality and cannot be changed after creation.
|
Scenario |
Recommendation |
|
General Chinese and English use cases |
|
|
In-house model available |
Use |
|
Dimension selection |
Higher dimensions improve semantics but increase storage and compute costs. 1024 suits most cases |
Metadata schema design
Metadata fields are immutable after creation. Follow these guidelines:
-
Plan ahead: Identify all filter dimensions (category, date, author, version, department) and define them at creation time.
-
Use the correct types: Use
datefor dates (notstring), andlongordoublefor numbers to enable range filtering withgreaterThanOrEquals.NoteSupported
dateformats:yyyy-MM-dd,yyyy-MM-dd HH:mm:ss,yyyy-MM-dd HH:mm:ss.SSS,yyyyMMdd HHmmss,yyyy-MM-dd'T'HH:mm:ss -
Limit the number of fields: Up to 200 fields are supported. Define only what you need.
-
Mind the total size limit: Total metadata size (keys + values) must not exceed 4 KB. Avoid long text values.
Subspace planning
|
Scenario |
Recommendation |
Reason |
|
Multi-tenant SaaS with homogeneous data |
Subspace |
Shares embedding config, reduces management overhead, enables cross-tenant search |
|
Different business lines with heterogeneous data |
Separate knowledge bases |
May require different embedding models and metadata schemas |
|
Very large tenant count (10,000+) |
Subspace |
Avoids excess knowledge bases. No subspace limit |
Document management
Consider per-request limits, OSS permissions, and status verification when importing documents.
Bulk document import
Each AddDocuments call accepts a maximum of 10 documents. For large-scale imports:
-
Batch your uploads: Send up to 10 documents per request. Call AddDocuments sequentially for each batch.
-
Control concurrency: Respect QPS limits to avoid throttling.
-
Wait asynchronously: After submitting all batches, poll statuses in a single pass.
-
Handle errors: Check each document's
statusindividually. Forfailedentries, log the reason, fix, and retry.
OSS file preparation
-
Grant the knowledge base service read and write access to the OSS bucket as described in Quick start.
-
Each file must not exceed 50 MB.
-
Use
inclusionFiltersandexclusionFiltersto import by OSS directory.*wildcards are supported, such as*.pdfand*report*.
Document status polling
Documents are indexed automatically. To verify completion, use exponential backoff.
|
Parameter |
Recommended value |
|
Initial interval |
3 seconds |
|
Backoff multiplier |
2 (doubles each time: 3s → 6s → 12s → ...) |
|
Maximum interval |
30 seconds |
|
Stop condition |
|
Processing time varies by file size and count. Exponential backoff outperforms fixed intervals for both short and long tasks.
Retrieval tuning
Select the search type, rerank strategy, and parameters that best match your queries.
Search type selection
|
Scenario |
Recommended type |
Description |
|
Natural-language questions |
|
Combines semantic and keyword matching |
|
Exact keywords or identifiers |
|
Vector search misses exact matches |
|
Pure semantic understanding |
|
For example, "how to install" matches "deployment steps" |
Reranking strategy selection
|
Strategy |
Pros |
Cons |
Use case |
|
WEIGHT |
Controls weight of each search type |
Requires manual parameter tuning |
When one search type dominates |
|
RRF |
No extra model call. Low latency and stable results |
No query-document interaction |
General-purpose scenarios |
|
MODEL |
Best ranking accuracy |
Higher latency and cost |
Accuracy-critical scenarios |
numberOfResults tuning
The search pipeline has three levels of numberOfResults:
-
N1 (
denseVectorSearchConfiguration.numberOfResults): Vector search recall count -
N2 (
fullTextSearchConfiguration.numberOfResults): Full-text search recall count -
N3 (
rerankingConfiguration.numberOfResults): Final count after reranking
N1 and N2 set the candidate pool. N3 sets the final count. Start with N1 = N2 = 20, N3 = 5–10.
Metadata filtering
-
Filters narrow the candidate set before search, improving both precision and performance.
-
Filter fields must be defined as metadata at creation time.
-
For date range filtering, use the
datetype to enable range comparison.
Common errors
|
Error code |
Meaning |
Common cause |
Solution |
|
|
Parameter validation failed |
Field type mismatch, length limit exceeded, or missing required field |
Verify that request parameters conform to the specification |
|
|
Resource does not exist |
Knowledge base name misspelled or already deleted |
Confirm that the resource name and ID exist |
|
|
Malformed request |
Invalid JSON format |
Check the JSON format of the request body |
|
|
Business validation failed |
RRF k value set to 0 or invalid search parameters |
Check parameter value ranges |
|
HTTP 200 + |
Request succeeded but document processing failed |
Metadata format mismatch, such as an incorrect date format |
Check |
An HTTP 200 with code: SUCCESS does not guarantee all entries succeeded. Check each entry's status individually.
Date formats
Supported date formats:
|
Format |
Example |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Unsupported formats cause a failed status during AddDocuments.
Irreversible operations
The following operations cannot be undone:
|
Operation |
Impact |
Recovery |
|
DeleteKnowledgeBase |
Deletes the knowledge base and all its documents and chunks |
Unrecoverable |
|
DeleteDocuments |
Deletes the specified documents and all their chunks |
Unrecoverable |
|
embeddingConfiguration |
Cannot be changed after creation |
Requires deleting and recreating the knowledge base |
|
metadata schema |
Fields cannot be added or removed after creation |
Requires deleting and recreating the knowledge base |
|
subspace switch |
Cannot be changed after creation |
Requires deleting and recreating the knowledge base |
|
UpdateDocument metadata |
Full replacement. All existing values are overwritten |
Re-submit the complete metadata |