Skip to content

Instantly share code, notes, and snippets.

@baditaflorin
Last active August 20, 2017 16:30
Show Gist options
  • Save baditaflorin/b1dc5c466abf9c214f7c8583bd9a72f7 to your computer and use it in GitHub Desktop.
Save baditaflorin/b1dc5c466abf9c214f7c8583bd9a72f7 to your computer and use it in GitHub Desktop.
select s.*,tag_name,title,mps.user_username,post_tags,article_url from (
SELECT post_id,ts_headline(text, keywords, 'MaxFragments=35,MaxWords=50,MinWords=6') as result
-- tweak the setting to reflect what you want. the text column is where i have the text
FROM medium_posts_text mptxt, plainto_tsquery('pg_catalog.english','training') as keywords
--change bot with the word that you are searching
WHERE to_tsvector(text) @@ keywords
) s
inner join medium_posts_tags mpt on mpt.post_id = s.post_id
inner join medium_posts_stats mps on mps.post_id = s.post_id
wHERE tag_name ilike 'Artificial Intelligence' or mpt.tag_name ilike 'Machine Learning' or mpt.tag_name ilike 'Deep Learning'
-- filter and keep just the tags that you want
limit 5000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment