@@ -160,7 +160,7 @@ public function add(VectorDocument ...$documents): void
160160 * semanticRatio?: float,
161161 * limit?: int,
162162 * where?: string,
163- * params?: array,
163+ * params?: array<string, mixed> ,
164164 * maxScore?: float
165165 * } $options
166166 */
@@ -196,14 +196,14 @@ public function query(Vector $vector, array $options = []): array
196196 }
197197 }
198198
199- if ($ options ['where ' ] ?? false ) {
199+ if (isset ( $ options ['where ' ]) && '' !== $ options [ ' where ' ] ) {
200200 $ where [] = '( ' .$ options ['where ' ].') ' ;
201201 }
202202
203203 $ whereClause = $ where ? 'WHERE ' .implode (' AND ' , $ where ) : '' ;
204204
205205 // Choose query strategy based on semanticRatio and query text
206- if (1.0 === $ semanticRatio || empty ( $ queryText) ) {
206+ if (1.0 === $ semanticRatio || '' === $ queryText ) {
207207 // Pure vector search
208208 $ sql = $ this ->buildVectorOnlyQuery ($ whereClause , $ limit );
209209 } elseif (0.0 === $ semanticRatio ) {
@@ -255,7 +255,7 @@ private function buildFtsOnlyQuery(string $whereClause, int $limit): string
255255 // Add FTS match filter to ensure only relevant documents are returned
256256 $ ftsFilter = \sprintf ("content_tsv @@ websearch_to_tsquery('%s', :query) " , $ this ->language );
257257
258- if ($ whereClause ) {
258+ if ('' !== $ whereClause ) {
259259 // Combine existing WHERE clause with FTS filter
260260 $ whereClause = str_replace ('WHERE ' , "WHERE $ ftsFilter AND " , $ whereClause );
261261 } else {
@@ -284,7 +284,7 @@ private function buildHybridQuery(string $whereClause, int $limit, float $semant
284284 $ ftsWhereClause = $ whereClause ;
285285 $ ftsFilter = \sprintf ("content_tsv @@ websearch_to_tsquery('%s', :query) " , $ this ->language );
286286
287- if ($ whereClause ) {
287+ if ('' !== $ whereClause ) {
288288 $ ftsWhereClause = str_replace ('WHERE ' , "WHERE $ ftsFilter AND " , $ whereClause );
289289 } else {
290290 $ ftsWhereClause = "WHERE $ ftsFilter " ;
0 commit comments