Search speaker names

pull/414/head
HeNine 3 years ago
parent 8be60d34b2
commit 25dc6c4261

@ -102,9 +102,9 @@ def fetch_lines(db_conn, start_time, end_time, ts_query=None, limit=None, offset
query = "SELECT * FROM buscribe_all_transcriptions WHERE start_time > %(start_time)s AND end_time < %(end_time)s " query = "SELECT * FROM buscribe_all_transcriptions WHERE start_time > %(start_time)s AND end_time < %(end_time)s "
if ts_query is not None: if ts_query is not None:
query += "AND transcription_line_ts @@ " \ query += "AND (coalesce(transcription_line_ts, ''::tsvector) || coalesce(names_ts, ''::tsvector)) @@ " \
"(CASE WHEN websearch_to_tsquery(%(text_query)s)::text != '' THEN websearch_to_tsquery(%(text_query)s)::text || ':*' ELSE '' END)::tsquery " \ "(CASE WHEN websearch_to_tsquery(%(text_query)s)::text != '' THEN websearch_to_tsquery(%(text_query)s)::text || ':*' ELSE '' END)::tsquery " \
"ORDER BY ts_rank_cd(transcription_line_ts, (CASE WHEN websearch_to_tsquery(%(text_query)s)::text != '' THEN websearch_to_tsquery(%(text_query)s)::text || ':*' ELSE '' END)::tsquery) DESC, " \ "ORDER BY ts_rank_cd(coalesce(transcription_line_ts, ''::tsvector) || coalesce(names_ts, ''::tsvector), (CASE WHEN websearch_to_tsquery(%(text_query)s)::text != '' THEN websearch_to_tsquery(%(text_query)s)::text || ':*' ELSE '' END)::tsquery) DESC, " \
"start_time " "start_time "
else: else:
query += "ORDER BY start_time " query += "ORDER BY start_time "

@ -86,7 +86,8 @@ SELECT buscribe_transcriptions.id,
coalesce(buscribe_verified_lines.verifier, speakers.verifier) AS verifier, coalesce(buscribe_verified_lines.verifier, speakers.verifier) AS verifier,
names, names,
verified_line AS transcription_line, verified_line AS transcription_line,
setweight(to_tsvector('english', verified_line), 'C') AS transcription_line_ts setweight(to_tsvector('english', verified_line), 'C') AS transcription_line_ts,
setweight(to_tsvector(array_to_string(names, ' ')), 'C') AS names_ts
FROM buscribe_transcriptions FROM buscribe_transcriptions
LEFT OUTER JOIN buscribe_verified_lines ON buscribe_transcriptions.id = buscribe_verified_lines.line LEFT OUTER JOIN buscribe_verified_lines ON buscribe_transcriptions.id = buscribe_verified_lines.line
LEFT OUTER JOIN ( LEFT OUTER JOIN (
@ -106,7 +107,8 @@ SELECT id,
null AS verifier, null AS verifier,
null AS names, null AS names,
transcription_line, transcription_line,
to_tsvector('english', transcription_line) AS transcription_line_ts to_tsvector('english', transcription_line) AS transcription_line_ts,
null AS names_ts
FROM buscribe_transcriptions; FROM buscribe_transcriptions;
ROLLBACK; ROLLBACK;
Loading…
Cancel
Save