Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: remove special handling for queries < 3 in length

Abdullah Attab32f6b2460ce
diff --git a/packages/core/src/api/lookup.ts b/packages/core/src/api/lookup.ts
index 920447efe..b81369b5f 100644
--- a/packages/core/src/api/lookup.ts
+++ b/packages/core/src/api/lookup.ts
@@ -47,60 +47,7 @@ export default class Lookup {
const db = this.db.sql() as unknown as Kysely<RawDatabaseSchema>;
const excludedIds = this.db.trash.cache.notes;
- // if (query.length <= 2) {
- // const results = await db
- // .selectFrom((eb) =>
- // eb
- // .selectFrom("notes")
- // .$if(!!notes, (eb) =>
- // eb.where("id", "in", notes!.filter.select("id"))
- // )
- // .$if(excludedIds.length > 0, (eb) =>
- // eb.where("id", "not in", excludedIds)
- // )
- // .where("title", "like", `%${query}%`)
- // .select(["id"])
- // .unionAll((eb) =>
- // eb
- // .selectFrom("content")
- // .$if(!!notes, (eb) =>
- // eb.where("id", "in", notes!.filter.select("id"))
- // )
- // .$if(excludedIds.length > 0, (eb) =>
- // eb.where("id", "not in", excludedIds)
- // )
- // .where("locked", "!=", true)
- // .where("data", "like", `%${query}%`)
- // .select(["noteId as id"])
- // .$castTo<{ id: string; dateCreated: number }>()
- // )
- // .as("results")
- // )
- // .select(["results.id"])
- // .groupBy("results.id")
- // .$if(!!limit, (eb) => eb.limit(limit!))
- // // filter out ids that have no note against them
- // .where(
- // "results.id",
- // "in",
- // (notes || this.db.notes.all).filter.select("id")
- // )
- // .execute()
- // .catch((e) => {
- // logger.error(e, `Error while searching`, { query });
- // return [];
- // });
- // return results.map((r) => r.id);
- // }
-
query = transformQuery(query);
- console.log(
- "TRANSFORMED",
- query,
- await sql`SELECT * from content_fts where data MATCH 'awesome'`.execute(
- db
- )
- );
const results = await db
.selectFrom((eb) =>
eb