Sandy
CCConvex Community
•Created by Sandy on 3/15/2024 in #show-and-tell
QueryCorner: An AI powered platform to accelerate your workflow
1 replies
CCConvex Community
•Created by Sandy on 3/13/2024 in #support-community
How to filter a search with tags?
I'm trying to filter posts based on their tags. User's can also filter by tags when searching posts. My question is how do I do a set intersection operation to check to see if a post has any one of the tags entered in the search query? Tags are just arrays of strings. Here is my query.
//Takes a query and optional tags and returns a list of posts that are similar to the query
export const similarPosts = action({
args: { query: v.string(), tags: v.optional(v.array(v.string())) },
handler: async (ctx, args) => {
const embedding = await embed(args.query);
const tags = args.tags;
let results;
if (tags !== undefined) {
results = await ctx.vectorSearch("posts", "by_embedding", {
vector: embedding,
limit: 16,
filter: (q) => q.eq("tags", tags) // Not sure how to structure the query here
});
} else {
results = await ctx.vectorSearch("posts", "by_embedding", {
vector: embedding,
limit: 16,
});
}
const rows: SearchResultVector[] = await ctx.runQuery(
internal.posts.fetchResults,
{ results },
);
console.log("search results for query", args.query);
return rows;
},
});
4 replies
CCConvex Community
•Created by Sandy on 3/12/2024 in #support-community
Paginate Vector Search Results
5 replies
CCConvex Community
•Created by Sandy on 3/11/2024 in #support-community
Best practices for getting liked posts
34 replies
CCConvex Community
•Created by Sandy on 3/6/2024 in #support-community
Trouble understanding team workflow using Convex.
15 replies