Repository navigation
[Vector Query]
#17366
Replies: 1 comment
|
PR #13559 did end up getting dropped. Vector query eventually landed through a different API, Firestore Pipelines. Since cloud_firestore 6.3.0, you do a vector query with findNearest inside a pipeline. To store the vectors, use VectorValue, which has been around since 5.6.0. final snapshot = await firestore
.pipeline()
.collection('books')
.findNearest(
Field('embedding'),
[0.1, 0.2, 0.3],
DistanceMeasure.cosine,
limit: 10,
distanceField: 'distance',
)
.execute();One requirement that's easy to miss: the embedding field needs a vector index in Firestore. Without one the query fails, and the console gives you a link to create the index. The results land in snapshot.result, with the distance attached to each document as the distance field. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi, I noticed that PR #13559 was closed with the reason "Was done in another PR". Could someone let me know which PR implemented this? Also, how can I perform a vector query now? Thanks!
All reactions