Rodrigo-RR
Convex Community2y ago
3 replies
Rodrigo-R

vectorSearch, filtering 2 fields using and

Hi!
In my schema i have a table with content, embedings, spaceId and partnerId, i want to search records only belonging to a spaceId AND partnerId, but the filter for vectorSearch only acceprs eq.or, i can't do an AND.
My vectorIndex is this:

.vectorIndex("by_embedding",{
vectorField: "embedding",
dimensions:1536,
filterFields:['spaceId', 'partnerId']
})
and in my action i want to filter out non related records like this:
const results = await ctx.vectorSearch("documents", "by_embedding", {
vector: embedding,
limit: 16,
filter: q => q.eq("spaceId", args.spaceId)
})

i want something like
q => q.and( q.eq("spaceId", 1), ( q.eq("partnerId", 1))
Is this possible?
Was this page helpful?