How do I query for urls in my database?

Hi, I’m trying to make a query that returns the urls from my database similar to the example query,

#+BEGIN_QUERY
{:title "Blocks that start with an https link"
 :query [:find (pull ?b [*])
         :in $ %
         :where (starts-with ?b "https://")]
 :rules [[(starts-with ?b ?substr)
         [?b :block/content ?content]
         [(clojure.string/starts-with? ?content ?substr)]]]}
#+END_QUERY

The above query doesn’t take into account “http://” and it only searches blocks that start with “https://”…

Ideally, I want to search the whole block for one or more instances of a url and return those. If this is not possible than at least return a url in the block if one is found (again looking through the entire block).

I’ve looked at various fragments of documentation on Datalog and tutorials, but been unable to figure out how to accomplish this. Hope someone here is more well versed in Datalog/querying, as this seems to make up half of what Logseq is all about.

Begin with something like this:

#+BEGIN_QUERY
{:title "Blocks that contain string http"
  :query [:find (pull ?b [*])
    :where
        [?b :block/content ?content]
        [(clojure.string/includes? ?content "http")]
  ]
}
#+END_QUERY
2 Likes