Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. ALTER TABLE companies
  2. ADD COLUMN tsq tsquery;
  3.  
  4. CREATE INDEX tsv_idx ON documents USING gin(tsq);
  5.  
  6. UPDATE companies
  7. SET tsq = to_tsquery(CAST(tin AS text)) ||
  8.  
  9. CASE
  10. WHEN numnode(plainto_tsquery('simple', "legalName")) > 0
  11.  
  12. THEN phraseto_tsquery('simple', replace("legalName", '"', ''))
  13.  
  14. ELSE '' END ||
  15.  
  16. CASE
  17. WHEN numnode(plainto_tsquery('simple', "shortName")) > 0
  18.  
  19. THEN phraseto_tsquery('simple', replace("shortName", '"', ''))
  20.  
  21. ELSE '' END
  22. WHERE id > 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement