logseq.DB.q - case insensitive search using logseq API

So in summary,

  • if I want a simple case insensitive search targeting the entire graph, then I can use logseq.App.Search (this is not documented as of now)
  • if I want advanced case insensitive search to search only on a specific page or tag etc… then I need to use logseq.DB.datascriptQuery along with regular expressions

example datascriptQuery (reference):


const tags: [string, string, BlockEntity][] = await logseq.DB.datascriptQuery(`
[:find ?id :in $ ?name :where [?id :block/name ?name]],
`, "\"home\"");

Example 2 (reference):

const page = await logseq.Editor.getCurrentPage();
const currentPageName = await page?.name;

const tags: [string, string, BlockEntity][] = await logseq.DB.datascriptQuery(`
  [:find ?content ?tag (pull ?b [*])
    :where
    [?b :block/refs ?page-ref]
    [?b :block/content ?content]
    [?page-ref :block/name ?tag]  
    [?page-ref :block/page ${currentPageName}]
  ]
`);