How to filter using any words in a field rather than all words?

Windows/Chrome v94.0.4606.71/TW v5.1.23

I have tiddlers with a keyword field that may contain 0 or more words. I want to create a filter that may contain several words any of which will match the list of words in the keyword field.

e.g., a tiddler’s keyword field contains text1 and text2. I want my filter to match on either of those words. So if my filter has text1 and text3 it would match my example tiddler.

I’ve seen the search:keyword[my search] filter operator but this only matches if the tiddler contains both words, evidently it does not match on either word.

I hope I explained the clearly.

Use the :intersection filter run prefix and the enlist[...] filter operator, like this:

{{{ [enlist{!!keyword}] :intersection[enlist[text1 text3]] }}}
2 Likes

Erics solution in making use of the recent intersection run prefix, nice.

If you look at https://tiddlywiki.com/#search%20Operator you will see there is a flag called words to

  • words: (the default) treats the search string as a list of tokens separated by whitespace, and matches if all of the tokens appear in the string (regardless of ordering and whether there is other text in between)

So it all depends on the logic you want; I suspect you would like something like this;

[search:keyword[word1] [ [search:keyword[word2] [search:keyword[word3] untested, but I expect this will return all tiddlers with one or more of matching words, it should deduplicate the list and you can add “+[sort[]]” at the end.

You could also use the Contains Operator again untested today

[all[tiddlers]contains:keyword[word1]] [all[tiddlers]contains:keyword[word2]] [all[tiddlers]contains:keyword[word3]]
Or even use Erics enlist trick