Query the top 4 latest results

Hi all.
I want to have a query to retrieve only the latest 4 information about a certain topic (page).
How to do that?

I am using (take N results) in the :result-transform function but it seems to give random results or, at least, not in order. I would need to take the4 most recent blocks.

@Siferiax any clues?

thanks

Sort the result first, then take 4.
E.g.

:result-transform (fn [result] 
  (take 4 
    (sort-by 
      (fn [r] (get r :block/journal-day)) 
      > result
    )
  ) 
)
1 Like

Thanks.
It is working but not always, sometimes it skips some results I dunno why….

Maybe there is something else in the code that causes conflict