Michael Rea
Michael Rea9mo ago

Vector search filter: Id NOT in array

const similarMessagesVectors = await ctx.vectorSearch("messageEmbeddings", "by_embedding", {
vector: promptEmbedding,
limit: 5,
filter: (q) => q.eq("userId", userId) && q.eq("chatId", chatId),
});
const similarMessagesVectors = await ctx.vectorSearch("messageEmbeddings", "by_embedding", {
vector: promptEmbedding,
limit: 5,
filter: (q) => q.eq("userId", userId) && q.eq("chatId", chatId),
});
I'm trying to vector search on messages but want to exclude a message (the most recent user prompt) based on Id before the search. Is this possible with the filter or does it just have to be done after?
2 Replies
lee
lee9mo ago
currently vector search filters only support OR and EQ, so there's no way to exclude a message and also the syntax (q) => q.eq("userId", userId) && q.eq("chatId", chatId) doesn't work. we've been thinking about how to support intersections in addition to unions, but it's not supported yet. i recommend picking the most restrictive filter (userId or chatId) as part of the vector search and post-filtering for the rest.
Michael Rea
Michael ReaOP9mo ago
Alright, cheers

Did you find this page helpful?