TripleSpeeder
TripleSpeeder•13mo ago

Strange error when trying to use search

I'm getting a strange error as soon as I'm trying to search on a table with searchIndex. Browser console keeps printing this, repeating forever:
WebSocket closed with code 1011: InternalServerError
_app-62f3ee54ceeb705a.js:4 Attempting reconnect in 51.837452158347006ms
_app-62f3ee54ceeb705a.js:4 WebSocket reconnected
_app-62f3ee54ceeb705a.js:4 WebSocket closed with code 1011: InternalServerError
_app-62f3ee54ceeb705a.js:4 Attempting reconnect in 67.02649050867504ms
_app-62f3ee54ceeb705a.js:4 WebSocket reconnected
WebSocket closed with code 1011: InternalServerError
_app-62f3ee54ceeb705a.js:4 Attempting reconnect in 51.837452158347006ms
_app-62f3ee54ceeb705a.js:4 WebSocket reconnected
_app-62f3ee54ceeb705a.js:4 WebSocket closed with code 1011: InternalServerError
_app-62f3ee54ceeb705a.js:4 Attempting reconnect in 67.02649050867504ms
_app-62f3ee54ceeb705a.js:4 WebSocket reconnected
I'm accessing this function from the convex dashboard:
export const testsearch = query({
args: {
query: v.optional(v.string()),
},
handler: async (ctx, { query }) => {
if (query && query.length > 0) {
return ctx.db
.query("partModel")
.withSearchIndex("search_component", (q) =>
q.search("component", query),
)
.collect();
} else {
return ctx.db.query("partModel").collect();
}
},
});
export const testsearch = query({
args: {
query: v.optional(v.string()),
},
handler: async (ctx, { query }) => {
if (query && query.length > 0) {
return ctx.db
.query("partModel")
.withSearchIndex("search_component", (q) =>
q.search("component", query),
)
.collect();
} else {
return ctx.db.query("partModel").collect();
}
},
});
When not providing a query the result is as expected. When providing a query string, the UI keeps loading forever and console shows above errors.
3 Replies
TripleSpeeder
TripleSpeederOP•13mo ago
searchindex is defined in my schema:
partModel: defineTable({
partGroupId: v.id("partGroup"),
manufacturerId: v.id("manufacturer"),
component: v.string(),
name: v.string(),
})
.searchIndex("search_component", {
searchField: "component",
filterFields: ["manufacturerId", "partGroupId"],
})
.searchIndex("search_name", {
searchField: "name",
filterFields: ["manufacturerId", "partGroupId"],
}),
partModel: defineTable({
partGroupId: v.id("partGroup"),
manufacturerId: v.id("manufacturer"),
component: v.string(),
name: v.string(),
})
.searchIndex("search_component", {
searchField: "component",
filterFields: ["manufacturerId", "partGroupId"],
})
.searchIndex("search_name", {
searchField: "name",
filterFields: ["manufacturerId", "partGroupId"],
}),
Same problems when using the query from my app with useQuery hook. Any ideas?
sshader
sshader•13mo ago
Hmm I'm seeing a similar issue with search in one of my apps, so I'm investigating if it's an issue on our side I believe this should now be resolved on our end -- let us know if you're still seeing these errors.
TripleSpeeder
TripleSpeederOP•13mo ago
Yes, working fine again. Thank you 🙂