A question about the search operator

105 views
Skip to first unread message

hubertgk

unread,
Mar 26, 2018, 12:05:44 PM3/26/18
to TiddlyWiki
Hi,

I know we're able to search within tiddler fields as explained in the documentation -- for example, the below syntax...

[search:caption[arch]]

...will return all tiddlers containing the search term arch in their caption field.

I was wondering if tiddlywiki allows searching, in a similar fashion, in the indexes of a data tiddler as well? In many scenarios, tiddlywiki treats fields and indexes in a similar way, however, the above syntax does not seem to work for indexes (I know search can be case-sensitive, but still I had no luck).

I was wondering if anyone has been able to build a list filter that could return all tiddlers containing a given search term as the value in a specified index? What would be the syntax, if the one above does not work?

In the ideal world,

[search:skill[advanced]]

...would return all (data) tiddlers with the value 'advanced' under the index 'skill'. Unfortunately, no luck.

I'd be extremely grateful for any help :-)

Thanks!











hubertgk

unread,
Mar 26, 2018, 1:04:29 PM3/26/18
to TiddlyWiki
I've found a way. So, just for the record, and to answer my own question, we can search in values of a specified index of a data tiddler by simply performing a full text search using a search term that's made up by the value being queried and the index that can be defined as a macro substitute, like here:

[search:text[skill: $(skill_level)$]]

having defined:

<$set name=skill_level value=advanced>
...
</$set>

This of course has limitations (possible false positives depending on a way the queried dataset is structured) but that's the only way I've found.

Still, looking forward to better solutions. Thanks!

BurningTreeC

unread,
Mar 26, 2018, 1:47:12 PM3/26/18
to TiddlyWiki
Hello @hubertgk

you could also do this with two filters

<$list filter="[all[tiddlers+shadows]type[application/json]]" variable="jsonTiddler">
<$list filter="[<jsonTiddler>indexes[]regexp[^skill$]]">

<<jsonTiddler>>

</$list>
</$list>


hubertgk

unread,
Mar 26, 2018, 2:08:35 PM3/26/18
to TiddlyWiki
Hi BurningTreeC and thanks for your input. Am I correct in saying that your code will search in indexes and not in their values?

I'm specifically looking to search in values.

Best regards,
Hubert

Stephan Hradek

unread,
Mar 27, 2018, 1:18:43 AM3/27/18
to TiddlyWiki
To search in the values, i'm not sure, but I think this would do:

<$list filter="[all[tiddlers+shadows]
type[application/json]]" variable="jsonTiddler">
<$list filter="[
<jsonTiddler>getindex[skill]search:title<skill_level>]">

<
<jsonTiddler>>

</$list>
</$list>


hubertgk

unread,
Mar 27, 2018, 9:49:20 AM3/27/18
to TiddlyWiki
Thanks Stephan, your suggestion worked. I've just had to change <skill_level> to [skill_level].

Thank you!
Regards,
Hubert
Reply all
Reply to author
Forward
0 new messages