diff options
author | Michael McVady <femtonaut@gmail.com> | 2024-01-12 16:33:49 -0600 |
---|---|---|
committer | Michael McVady <femtonaut@gmail.com> | 2024-01-12 16:33:53 -0600 |
commit | dd5411a8d709520c19a2e3577064b6c1bc289e64 (patch) | |
tree | d44967e5fad879a7575e3bb8155e96aba109bf5f /src/queries.h | |
parent | 660d6e73218229c6ac08ac2b7a19819169529fc8 (diff) |
Stub out search ...
Diffstat (limited to 'src/queries.h')
-rw-r--r-- | src/queries.h | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/queries.h b/src/queries.h index f406434..a55fafb 100644 --- a/src/queries.h +++ b/src/queries.h @@ -8,19 +8,16 @@ const char *q_select_entries = "FROM entries " "ORDER BY updated_at DESC;"; -// const char *q_insert_entry = -// "INSERT INTO entries " -// "(title, body) " -// "VALUES " -// "($1, $2) " -// "RETURNING id;"; - -// const char *q_insert_entry_with_id = -// "INSERT INTO entries " -// "(id, title, body) " -// "VALUES " -// "($1, $2, $3) " -// "RETURNING id;"; +const char *q_search_entries = +"WITH query AS " +"( " +" SELECT id, title, created_at::DATE, updated_at::DATE, " +" TS_RANK(search_vector, TO_TSQUERY('english', $1)) AS rank " +" FROM entries " +" WHERE search_vector @@ TO_TSQUERY('english', $2) " +" ORDER BY rank DESC " +") " +"SELECT id, title, created_at::DATE, updated_at::DATE FROM query;"; const char *q_update_entry = "UPDATE entries " |