feat: add search menu to all resources
This commit is contained in:
@ -13,6 +13,12 @@ export const handler: Handlers = {
|
||||
|
||||
const query_by = url.searchParams.get("query_by") || "name,description";
|
||||
|
||||
let filter_by = "";
|
||||
const type = url.searchParams.get("type");
|
||||
if (type) {
|
||||
filter_by = `type:=${type}`;
|
||||
}
|
||||
|
||||
const typesenseClient = await getTypeSenseClient();
|
||||
if (!typesenseClient) {
|
||||
throw new Error("Query not available");
|
||||
@ -23,7 +29,7 @@ export const handler: Handlers = {
|
||||
.documents().search({
|
||||
q: query,
|
||||
query_by,
|
||||
limit_hits: 100,
|
||||
filter_by,
|
||||
});
|
||||
|
||||
return json(searchResults.hits);
|
||||
|
Reference in New Issue
Block a user