Skip to content

Instantly share code, notes, and snippets.

@documentcloud
Created October 31, 2009 17:37
Show Gist options
  • Save documentcloud/223158 to your computer and use it in GitHub Desktop.
Save documentcloud/223158 to your computer and use it in GitHub Desktop.
SELECT distinct on (documents.id) documents.*
FROM "documents"
WHERE (documents.id in (
(select document_id from metadata where
(metadata.kind = E'person' and
to_tsvector('english', metadata.value) @@ plainto_tsquery(E'bush')))
intersect
(select document_id from metadata where
(metadata.kind = E'city' and
to_tsvector('english', metadata.value) @@ plainto_tsquery(E'washington')))))
LIMIT 10 OFFSET 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment