Ancestors and descendants filter operators

Some of the feedback for the Recursive filter operators to show all tiddlers beneath a tag and all tags above a tiddler was the request to be able to use fields other than tags to connect tiddlers. After some reworking, these are the results:

Both allow to define an optional field to use, as well as to optionally limit the number of hierarchy levels to traverse. By default, tags is used with unlimited recursion, yielding identical results to tagstree and taggingtree.

For speed comparison, here is a quite extreme example (a wiki with 8,500 tiddlers out of which ≈ 3,600 are descendants of the base tiddler Origin via tags):

Filter Median time Uses Total time Total time (last 10) Longest run Average time
[[Origin]kin:tags:to[]count[]] 7336.50ms 10 73235.00ms 73235.00ms 7386.00ms 7323.50ms
[[Origin]descendants[]count[]] 11.50ms 10 114.00ms 114.00ms 14.00ms 11.40ms

Yes, descendants is 600× faster here. The difference will be much less for smaller wikis and fewer results and recursion levels, though. Also, using fields other than tags with ancestors and descendants will also be somewhat slower.

Let me know if you run into any problems.

Yaisog

7 Likes

Thanks @Yaisog! I can also confirm it works as expected (order) - thanks again!

Just for your knowledge, for my use case (kin:list:from[] vs. ancestors[list]prepend[root]) I’m now getting almost the same time in my 900 tiddler test, so I’m guessing most of the speed improvement is on the tags side and/or in the other direction (descendant vs. kin:tags:to). I have a feeling the loop protection and sort order recently added might’ve slightly slowed things down a bit for my use case.

Useful alternatives though! :slight_smile: