Commit c9c0a42f authored by Chunchi Che's avatar Chunchi Che

Merge branch 'feature/searchCard' into 'main'

feat: support keywords for search

See merge request !298
parents d49f1d95 7af3e605
Pipeline #23385 passed with stages
in 15 minutes and 41 seconds
...@@ -25,17 +25,18 @@ export function invokeFts(db: Database, params: FtsParams): CardMeta[] { ...@@ -25,17 +25,18 @@ export function invokeFts(db: Database, params: FtsParams): CardMeta[] {
const { query, conditions } = params; const { query, conditions } = params;
const ftsMetas: CardMeta[] = []; const ftsMetas: CardMeta[] = [];
const queryList = query.trim().split(" ");
const filterConditions = getFtsCondtions(conditions); const filterConditions = getFtsCondtions(conditions);
const stmt = db.prepare(` const stmt = db.prepare(`
SELECT datas.*, texts.* SELECT datas.*, texts.*
FROM datas FROM datas
INNER JOIN texts ON datas.id = texts.id INNER JOIN texts ON datas.id = texts.id
WHERE texts.name LIKE $query ${ WHERE (texts.name || texts.desc) LIKE $query
filterConditions ? `AND ${filterConditions}` : "" ${filterConditions ? `AND ${filterConditions}` : ""}
}
`); `);
stmt.bind({ $query: `%${query}%` }); stmt.bind({ $query: `%${queryList.join("%")}%` });
while (stmt.step()) { while (stmt.step()) {
const row = stmt.getAsObject() as CardData & CardText; const row = stmt.getAsObject() as CardData & CardText;
......
...@@ -379,7 +379,7 @@ const Search: React.FC = () => { ...@@ -379,7 +379,7 @@ const Search: React.FC = () => {
<div className={styles.container} ref={dropRef}> <div className={styles.container} ref={dropRef}>
<div className={styles.title}> <div className={styles.title}>
<Input <Input
placeholder="搜索卡片" placeholder="关键词(空格分隔)"
bordered={false} bordered={false}
suffix={ suffix={
<Button <Button
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment