mem0ai/mem0 · error · Error
Unsupported distance metric: ${config.distanceMetric}
Error message
Unsupported distance metric: ${config.distanceMetric} What it means
The distance metric is stored in the vector index DDL and used to convert distance to a similarity score, so it must be one of the six supported Oracle VECTOR_DISTANCE functions: COSINE, EUCLIDEAN, EUCLIDEAN_SQUARED, DOT, HAMMING, MANHATTAN. The value is uppercased before the check, so 'cosine' is accepted; anything else fails, echoing the original config value in the message.
Source
Thrown at mem0-ts/src/oss/src/vector_stores/oracledb.ts:351
this.collectionName = quoteIdentifier(config.collectionName || "mem0");
this.indexName = quoteIdentifier(
config.indexName || `${config.collectionName || "mem0"}_VEC_IDX`,
);
this.embeddingModelDims = config.embeddingModelDims ?? 1536;
if (
!Number.isInteger(this.embeddingModelDims) ||
this.embeddingModelDims <= 0
) {
throw new Error("`embeddingModelDims` must be a positive integer");
}
const distanceMetric = (config.distanceMetric ??
"COSINE") as string as DistanceMetric;
this.distanceMetric = distanceMetric.toUpperCase() as DistanceMetric;
if (!DISTANCE_METRICS.includes(this.distanceMetric)) {
throw new Error(`Unsupported distance metric: ${config.distanceMetric}`);
}
const indexType = (config.indexType ?? "HNSW") as string;
this.indexType = indexType.toUpperCase() as IndexType;
if (this.indexType !== "HNSW" && this.indexType !== "IVF") {
throw new Error(`Unsupported index type: ${config.indexType}`);
}
this.indexAccuracy = config.indexAccuracy;
if (
this.indexAccuracy !== undefined &&
(!Number.isInteger(this.indexAccuracy) ||
this.indexAccuracy <= 0 ||
this.indexAccuracy > 100)
) {
throw new Error("`indexAccuracy` must be an integer between 1 and 100");
}
View on GitHub (pinned to 001c235229)
Solutions
- Use one of: COSINE, EUCLIDEAN, EUCLIDEAN_SQUARED, DOT, HAMMING, MANHATTAN (case-insensitive).
- Map other backends' names: Qdrant 'Dot' → DOT, 'Euclid' → EUCLIDEAN; pgvector 'l2' → EUCLIDEAN, '<#>' → DOT.
- Omit distanceMetric to get the COSINE default, which matches most normalized-embedding setups.
- If porting a config file, grep it for old metric names before switching stores.
Example fix
// before
new OracleDB({ connectionParams, distanceMetric: 'l2' });
// after
new OracleDB({ connectionParams, distanceMetric: 'EUCLIDEAN' }); Defensive patterns
Strategy: validation
Validate before calling
const ORACLE_METRICS = new Set(['COSINE','EUCLIDEAN','EUCLIDEAN_SQUARED','DOT','HAMMING','MANHATTAN']);
function normalizeMetric(m?: string): string | undefined {
if (!m) return undefined;
const upper = m.toUpperCase();
if (!ORACLE_METRICS.has(upper)) throw new RangeError(`Unsupported distance metric '${m}'. Valid: ${[...ORACLE_METRICS].join(', ')}`);
return upper;
} Type guard
const isOracleMetric = (v: string): v is 'COSINE'|'EUCLIDEAN'|'EUCLIDEAN_SQUARED'|'DOT'|'HAMMING'|'MANHATTAN' => ORACLE_METRICS.has(v.toUpperCase());
Prevention
- Translate metric names when porting configs from Qdrant/pgvector (Dot→DOT, l2→EUCLIDEAN).
- Default to COSINE for normalized embeddings and omit the option.
When it happens
Trigger: distanceMetric: 'euclidean' works (uppercased) but 'l2' fails; 'cosine-similarity', 'IP' (a Qdrant name), 'l2_sq' (pgvector name), or undefined-typo metrics fail. Note the message prints the raw config value, e.g. "Unsupported distance metric: l2".
Common situations: Porting configs from other vector stores: Qdrant uses 'Cosine'/'Dot'/'Euclid', pgvector uses '<->' or 'l2'; misspellings like 'COSIN'; binary-embedding setups where 'hamming' is correct but users type 'hamming-distance'.
Related errors
- Must provide at least one of `connectionParams` and `client`
- `embeddingModelDims` must be a positive integer
- Unsupported index type: ${config.indexType}
- `indexAccuracy` must be an integer between 1 and 100
- Unsupported ${this.indexType} index parameter '${key}'. Allo
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/b4d07a6ac703a716.
Report an issue: GitHub.