Skip to content

Instantly share code, notes, and snippets.

@dorianmariecom
Created March 12, 2022 20:07
Show Gist options
  • Save dorianmariecom/a09932e677c46ce50e70e57232218cad to your computer and use it in GitHub Desktop.
Save dorianmariecom/a09932e677c46ce50e70e57232218cad to your computer and use it in GitHub Desktop.
irb(main):008:0> Search.new(scope: Item.all, query: "(ruby or Ruby) and extras.user:luci
usdomitius", schema: Item::SCHEMA).resolve.pluck(:content)
Item Pluck (17.3ms) SELECT "items"."content" FROM "items" WHERE (to_tsvector(coalesce(id::text, '') || ' ' || coalesce(kind::text, '') || ' ' || coalesce(external_id::text, '') || ' ' || coalesce(external_created_at::text, '') || ' ' || coalesce(title::text, '') || ' ' || coalesce(content::text, '') || ' ' || coalesce(url::text, '') || ' ' || coalesce(created_at::text, '') || ' ' || coalesce(updated_at::text, '') || ' ' || coalesce(extras->>'parent_item_id'::text, '') || ' ' || coalesce(extras->>'context_item_id'::text, '') || ' ' || coalesce(extras->>'next_item_id'::text, '') || ' ' || coalesce(extras->>'user'::text, '') || ' ' || coalesce(extras->>'html'::text, '') || ' ') @@ websearch_to_tsquery('english', 'ruby') OR to_tsvector(coalesce(id::text, '') || ' ' || coalesce(kind::text, '') || ' ' || coalesce(external_id::text, '') || ' ' || coalesce(external_created_at::text, '') || ' ' || coalesce(title::text, '') || ' ' || coalesce(content::text, '') || ' ' || coalesce(url::text, '') || ' ' || coalesce(created_at::text, '') || ' ' || coalesce(updated_at::text, '') || ' ' || coalesce(extras->>'parent_item_id'::text, '') || ' ' || coalesce(extras->>'context_item_id'::text, '') || ' ' || coalesce(extras->>'next_item_id'::text, '') || ' ' || coalesce(extras->>'user'::text, '') || ' ' || coalesce(extras->>'html'::text, '') || ' ') @@ websearch_to_tsquery('english', 'Ruby')) AND (to_tsvector(coalesce(extras->>'user'::text, '') || ' ') @@ websearch_to_tsquery('english', 'luciusdomitius'))
=> ["JetBrains is headquartered in Prague, Czech Republic and the leadership most probably don't approve of what is going on. \nAre you sure you want to cut some people off just because of where they were born to whom? This is really low, besides the alternatives for Ruby would be either Sublime or some electron-based crap - vscode, atom, etc."]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment