2016-04-03 12 views
-1

Wie mache ich eine Volltextsuche in Postgres aller Spalten ohne Vorverarbeitung? Ich habe http://www.postgresql.org/docs/9.3/static/textsearch-intro.html gefunden Ich bin mir nicht genau sicher, was ich tun muss.Volltextsuche mit Postgres

Mein erster Eindruck ist Ich muss auto jede Spalte verketten (wie kann ich das tun? Kann nicht über googeln finden) steckte es in eine WHERE und tun @@ to_tsquery

Das für https://github.com/timwis/node-soda2-parser/issues/1 ist, ich bin nicht mit schlechter Leistung besorgt

ich mit

select array_to_string(translate(string_to_array(r::text, ',')::text, '()', '')::text[], ' ')::tsvector FROM seattle_police_govqa_audit_trails as r LIMIT 1 

versuchten Start aber erhalten:

{"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"} 

Antwort

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