I have a table named results:
integer: id
json: websites
An example of websites column is:
[{"url": "http://google.com"}, {"url": "http://example.com"}]
What I want to do is generate a binary appearance chart, where it shows a 1 or a 0 depending on if ANY url in the JSON blob is contained within another set.
All the possibilities are on columns, and all the results are as rows.
result_id | wikipedia.org | google.com | example.com
10 1 1 1
11 0 1 0
12 0 0 0
13 1 0 0
- For it to return
1, ANY url in the JSON array object (with key->>{'url'}) must match the domain - The URLs are full urls so ideally I would like to use regex to check if its a match (i can't do a full string match because I only care about the HOST of the URL). I'm thinking something like
/https?:\/\/(example\.com)(/|?|$)/