{"record":{"id":"c1909ac920763e76","repo":"mongodb/laravel-mongodb","slug":"this-method-is-not-supported-by-mongodb-use-vectorsearch-c1909a","errorCode":null,"errorMessage":"This method is not supported by MongoDB. Use vectorSearch() with the $filter parameter instead.","messagePattern":"This method is not supported by MongoDB\\. Use vectorSearch\\(\\) with the \\$filter parameter instead\\.","errorType":"exception","errorClass":"BadMethodCallException","httpStatus":null,"severity":"error","filePath":"src/Query/Builder.php","lineNumber":2031,"sourceCode":"     * Base method from Laravel >= 13.0\n     * ToDo: mark as `#[Override]` when we drop support for Laravel < 13.0\n     *\n     * @internal This method is not supported by MongoDB. Use vectorSearch() instead.\n     */\n    public function whereVectorSimilarTo($column, $vector, $minSimilarity = 0.6, $order = true)\n    {\n        throw new BadMethodCallException('This method is not supported by MongoDB. Use vectorSearch() instead.');\n    }\n\n    /**\n     * Base method from Laravel >= 13.0\n     * ToDo: mark as `#[Override]` when we drop support for Laravel < 13.0\n     *\n     * @internal This method is not supported by MongoDB. Use vectorSearch() with the $filter parameter instead.\n     */\n    public function whereVectorDistanceLessThan($column, $vector, $maxDistance, $boolean = 'and')\n    {\n        throw new BadMethodCallException('This method is not supported by MongoDB. Use vectorSearch() with the $filter parameter instead.');\n    }\n\n    /**\n     * Base method from Laravel >= 13.0\n     * ToDo: mark as `#[Override]` when we drop support for Laravel < 13.0\n     *\n     * @internal This method is not supported by MongoDB. Use vectorSearch() with the $filter parameter instead.\n     */\n    public function orWhereVectorDistanceLessThan($column, $vector, $maxDistance)\n    {\n        throw new BadMethodCallException('This method is not supported by MongoDB. Use vectorSearch() with the $filter parameter instead.');\n    }\n\n    /**\n     * Base method from Laravel >= 13.0\n     * ToDo: mark as `#[Override]` when we drop support for Laravel < 13.0\n     *\n     * @internal This method is not supported by MongoDB. Use vectorSearch() instead, which returns vectorSearchScore in the result.","sourceCodeStart":2013,"sourceCodeEnd":2049,"githubUrl":"https://github.com/mongodb/laravel-mongodb/blob/0634653039468ceb0268a69192bdac64469ed043/src/Query/Builder.php#L2013-L2049","documentation":"whereVectorDistanceLessThan is a Laravel >= 13.0 vector method combining a vector search with a max-distance filter; MongoDB's builder throws BadMethodCallException because Atlas Vector Search expresses such constraints via the $filter parameter of vectorSearch(), not as where clauses.","triggerScenarios":"Calling ->whereVectorDistanceLessThan($column, $vector, $maxDistance) on a MongoDB query builder.","commonSituations":"Porting SQL/pgvector distance filters; mixing Laravel's portable vector API with a MongoDB connection after a framework upgrade.","solutions":["Use vectorSearch() and pass distance/prefilter constraints through its $filter parameter","Express the constraint with a supported pre-filter (e.g. a range filter on a stored field) in the $filter argument","Catch BadMethodCallException and rewrite the query with vectorSearch($filter: ...)"],"exampleFix":"// before\nDoc::whereVectorDistanceLessThan('embedding', $vec, 0.5)->get();\n// after\nDoc::vectorSearch('embedding', $vec, ['filter' => ['field' => 'category', 'in' => $cats]])->get();","handlingStrategy":"try-catch","validationCode":"if ($query instanceof MongoDB\\Query\\Builder) { $query->vectorSearch($col, $vec, ['filter' => $filter])->get(); } else { $query->whereVectorDistanceLessThan($col, $vec, $maxDistance)->get(); }","typeGuard":null,"tryCatchPattern":"try { $q->whereVectorDistanceLessThan($col, $vec, $d); } catch (\\BadMethodCallException $e) { $q->vectorSearch($col, $vec, ['filter' => $d]); }","preventionTips":["Express distance constraints as vectorSearch $filter options","Do not mix portable vector where-clauses with MongoDB connections","Pin and review the library's UPGRADING notes when bumping Laravel"],"tags":["query-builder","vector-search","unsupported-method","mongodb"],"backgroundTag":"unsupported-operation","analyzedSha":"0634653039468ceb0268a69192bdac64469ed043","analyzedAt":"2026-09-15T02:56:37.067Z","contentChangedAt":"2026-09-15T02:56:37.067Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}