A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix: Change search endpoint to accept query as raw string
Mohamed Bassemce16eda75f4d
diff --git a/apps/web/components/dashboard/search/SearchInput.tsx b/apps/web/components/dashboard/search/SearchInput.tsxindex ace3d785..5e46fc18 100644--- a/apps/web/components/dashboard/search/SearchInput.tsx+++ b/apps/web/components/dashboard/search/SearchInput.tsx@@ -84,7 +84,7 @@ const SearchInput = React.forwardRef<}}/><QueryExplainerTooltip- className="-translate-1/2 absolute right-1.5 top-2 p-0.5"+ className="-translate-1/2 absolute right-1.5 top-2 stroke-foreground p-0.5"parsedSearchQuery={parsedSearchQuery}/>{parsedSearchQuery.result === "full" &&diff --git a/apps/web/lib/hooks/bookmark-search.ts b/apps/web/lib/hooks/bookmark-search.tsindex 4662ffb6..386355f7 100644--- a/apps/web/lib/hooks/bookmark-search.ts+++ b/apps/web/lib/hooks/bookmark-search.ts@@ -52,7 +52,7 @@ export function useDoBookmarkSearch() {}export function useBookmarkSearch() {- const { parsedSearchQuery } = useSearchQuery();+ const { searchQuery } = useSearchQuery();const {data,@@ -64,8 +64,7 @@ export function useBookmarkSearch() {isFetchingNextPage,} = api.bookmarks.searchBookmarks.useInfiniteQuery({- text: parsedSearchQuery.text,- matcher: parsedSearchQuery.matcher,+ text: searchQuery,},{placeholderData: keepPreviousData,diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.tsindex 47ba623b..f3884053 100644--- a/packages/trpc/routers/bookmarks.ts+++ b/packages/trpc/routers/bookmarks.ts@@ -47,7 +47,6 @@ import {zNewBookmarkRequestSchema,zUpdateBookmarksRequestSchema,} from "@hoarder/shared/types/bookmarks";-import { zMatcherSchema } from "@hoarder/shared/types/search";import type { AuthedContext, Context } from "../index";import { authedProcedure, router } from "../index";@@ -525,7 +524,6 @@ export const bookmarksAppRouter = router({.input(z.object({text: z.string(),- matcher: zMatcherSchema.optional(),cursor: z.object({offset: z.number(),@@ -553,10 +551,14 @@ export const bookmarksAppRouter = router({message: "Search functionality is not configured",});}+ const parsedQuery = parseSearchQuery(input.text);let filter: string[];- if (input.matcher) {- const bookmarkIds = await getBookmarkIdsFromMatcher(ctx, input.matcher);+ if (parsedQuery.matcher) {+ const bookmarkIds = await getBookmarkIdsFromMatcher(+ ctx,+ parsedQuery.matcher,+ );filter = [`userId = '${ctx.user.id}' AND id IN [${bookmarkIds.join(",")}]`,];@@ -564,7 +566,7 @@ export const bookmarksAppRouter = router({filter = [`userId = '${ctx.user.id}'`];}- const resp = await client.search(input.text, {+ const resp = await client.search(parsedQuery.text, {filter,showRankingScore: true,attributesToRetrieve: ["id"],