Pietro
Pietro12mo ago

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" }),
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;
},
});
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;
},
});
3 Replies
ian
ian12mo ago
Are you on convex 1.7.1 or greater? I ask b/c I hit this yesterday and was on 1.5 and had forgotten to update
Pietro
PietroOP12mo ago
Yeah that was it. I wasn't aware of versioning being a thing, assumed convex was its own thing allways on latest. Thanks.
ian
ian12mo ago
We could have applied the behavior to older clients but we didn't want to break anyone relying on old behavior without them explicitly updating

Did you find this page helpful?