如何在没有预处理的情况下在Postgres中对所有列进行全文搜索?我发现http://www.postgresql.org/docs/9.3/static/textsearch-intro.html我不确定我需要做什么。
我最初的印象是我需要自动连接每一列(我该怎么做?无法通过Google搜索找到)把它放在WHERE中并执行@@ to_tsquery
这是针对https://github.com/timwis/node-soda2-parser/issues/1我并不关心糟糕的表现
我尝试从
开始select array_to_string(translate(string_to_array(r::text, ',')::text, '()', '')::text[], ' ')::tsvector FROM seattle_police_govqa_audit_trails as r LIMIT 1
但是得到:
{"readyState":4,"responseText":"{\"error\":[\"syntax error in tsvector: \\\"1 -1 -1 -1 -1 -1 0 0 1 1 2 3 3500 5 7007 198 1264 NULL NULL \\\"Answer created by staff\\\" NULL NULL \\\"9/24/2015 16:01\\\" A000198-092415\\\"\"]}","responseJSON":{"error":["syntax error in tsvector: \"1 -1 -1 -1 -1 -1 0 0 1 1 2 3 3500 5 7007 198 1264 NULL NULL \"Answer created by staff\" NULL NULL \"9/24/2015 16:01\" A000198-092415\""]},"status":400,"statusText":"Bad Request"}
答案 0 :(得分:0)
select * FROM seattle_police_govqa_audit_trails as r WHERE regexp_replace(array_to_string(translate(string_to_array(r::text, ',')::text, '()', '')::text[], ' '), '[^a-zA-Z\s]', '', 'g')::tsvector @@ 'created'::tsquery = true LIMIT 10