Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. CREATE INDEX pgweb_idx ON pgweb
  2. USING gin(to_tsvector('english', title || ' ' || body));
  3.  
  4. ... WHERE
  5. (to_tsvector('english', title||' '||body) @@ to_tsquery('english', 'foo'))
  6.  
  7. ... WHERE
  8. (to_tsvector('english', title) @@ to_tsquery('english','foo'))
  9. OR
  10. (to_tsvector('english', body) @@ to_tsquery('english','foo'))
  11.  
  12. --search any "field" for quick:
  13. select 'quick:1A brown:2B quick:3C'::tsvector @@ 'quick'::tsquery; --true
  14.  
  15. --search B "field" for quick:
  16. select 'quick:1A brown:2B quick:3C'::tsvector @@ 'quick:B'::tsquery; --false
  17.  
  18. --search B or C "fields" for quick:
  19. select 'quick:1A brown:2B quick:3C'::tsvector @@ 'quick:BC'::tsquery; --true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement