PietroP
Convex Community3y ago
4 replies
Pietro

Prefix Search requires v1.7 or greater

Prefix search doesn't seem to work for me, still catching full words only... not suitable for type ahead cases. Do I need to push some button or reset my DB or something for this to work?

I get 0 hits until type the first full word... this is a Development environment that was running before the upgrade. I've ran npm convex dev etc.
Thanks in advance for any tips.



  person: defineTable({
    name: v.string(),

  }).searchIndex("person_by_name_2", { searchField: "name" }),

export const get = query({
  args: {
    query: v.string(),
  },
  handler: async (ctx, args) => {
    const x = await ctx.db
      .query("person")
      .withSearchIndex("person_by_name_2", (q) => q.search("name", args.query))
      .take(5);
    console.log("get: ", args.query, " - ", x?.length);

    return x;
  },
});
Was this page helpful?