Indexing: add additional functions?

It's a bit hard to explain, what I'm trying to achieve, so I'll try to start with an example:

Let's say I have a journal and on each journalpage I have some data in the frontmatter section like my working times. e.g.

---
starttime: 09:00
endtime: 15:00
---

Now I have some functions to calculate the workingtime for a day. That works fine with queries, too. However, when I have quite a lot days to calculate (e.g. if I want to see the working time for a whole month or even a year), that query runs quite a while.

My idea would be to add kind of "hidden" additional field to the page object, containing the calculated time, so I could access the ready calculated data, e.q. via query that, too.
Adding the field itself should not be a problem (if I understood the index.indexObjects(page, objects) API correctly).
However, I wonder, if it is possible to somehow do the calculation while indexing, as the indexer have to read the page anyway on startup and on page changes.

So is it possible for a user to somehow extend the indexer in that manner?

Thanks for all ideas and / or explanations :slight_smile:

P.S.: Another solution could be to add the calculated data to the frontmatter-section, too. But then I have to update the values on every change, which sounds quite complicated...

This is still experimental, but have a look at this: tag

Especially the pageDecorator example that is close to what you’re trying to do.

Thanks a lot, @zef! That sounds exactly what I'm after. Now I have to look deeper how I can utilize that :slight_smile: