Filter: tiddlers with a particular tag together with tiddlers that have a prefix of those tiddlers in the title

I need help creating a search filter for Tiddlywiki that lists all the tiddlers with the currentPatient tag plus all the tiddlers that have a prefix starting with the title of the tiddlers with the CurrentPatient tag. Could you help create one? If it helps, those tiddlers also have another tag called ‘patientNotes’. I’ve tried Gemini 2.5 pro and ChatGPT 4o and they failed spectacularly.

I want to be able to enter the filter into the advanced search and export the tiddlers listed.

Conveniently, a tiddler is always prefixed with itself, so prefix[Patient A] will find both Patient A and Patient A Notes (as well as Patient ABC, etc.) This means all we need to do is:

  1. Get a list of all tiddlers with the currentPatient tag
    Filter: [tag[currentPatient]]

  2. Convert that list to a list of all tiddlers prefixed with any of the tiddlers found by the previous filter run.
    Filter: :map:flat[all[tiddlers]prefix<currentTiddler>]

The :map filter run prefix is a special kind of secondary filter prefix that says, "evaluate the following filter for each output of the previous filter, treating that output as <<currentTiddler>>". The additional :flat suffix ensures that we’ll get all tiddlers that match the filter, not just the first result for each input value.

Stringing it together, we get this:

[tag[currentPatient]] :map:flat[all[tiddlers]prefix<currentTiddler>] +[unique[]]

And since a :map run can potentially produce duplicate results, I added +[unique[]] at the end.

Let me know how it goes!

That is amazing! Many thanks. It worked like a charm. Thanks for beating AI. :slight_smile: