Closed flexchar closed 1 year ago
Hi @flexchar, you'll want to pass a Vector
instead of an array.
->orderByRaw('embedding <-> ?', [new Vector($embedding)])
Yes, I've missed that from the docs. Thank you for helping out!
Hi
I'm getting the same error when I use DB , not sure why
use Pgvector\Vector;
$embedding = new Vector([3,1,2]);
$documents = DB::table('documents')
->whereRaw("collection_id=?", [$collection_id])
->orderByRaw("embeds <-> '?'", [$embedding])
->limit(5)
->get();
SQLSTATE[HY093]: Invalid parameter number: parameter was not defined (Connection: pgsql, SQL: select * from "documents" where collection_id=1 order by embeds <-> '[3,1,2]' limit 5)
Hi @mrahmadt, make sure the question mark isn't in quotes.
->orderByRaw("embeds <-> ?", [$embedding])
Hi @mrahmadt, make sure the question mark isn't in quotes.
->orderByRaw("embeds <-> ?", [$embedding])
Woundfull, working perfectly now.
Latest versions of Laravel 10 and PHP 8.2.5. Using pgvector docker image for the server.
I'm trying to query pgsql using Laravel
->orderByRaw
method and I get:If I log query using ray (equal to dump), it seems that I'm only getting first float out of 1536 existing in the vector.
I tried nesting it into another array but it doesn't seem to take it in. I'm lost and would like some help :)