Combo Searchbox: search both as "standard search" and "filter search"

141 views
Skip to first unread message

Mohammad

unread,
Dec 19, 2019, 1:00:17 AM12/19/19
to tiddl...@googlegroups.com
This may be answered already, but I could not find in in the forum


idea: have a search box (an $edit-text) which lets you to search both by filter and by simple keywords
use case: one search box and do both standard and filter search

a quick proposal

put the below text inside and give a try.
perform searches like standard search and then like filter search and let me know your feedback.

\define standardSearch()
Standard search<br><!--for debugging-->
<$list filter="[search:title,caption,text[$(searchTerms)$]]">
<$link/><br>
</$list>
\end

\define filterSearch()
Filter search<br><!--for debugging-->
<$list filter=<<searchTerms>> >
<$link/><br>
</$list>
\end

\define combo-search()
<$vars pattern="^\["
       stateTid="$:/temp/comboSearch">
 
<!--UI -->
combo search &nbsp;<$edit-text tiddler=<<stateTid>> tag=input/>  

<!-- show results if any-->
<$reveal state=<<stateTid>> type="nomatch" text=""><!--do not display when searchbox is empty-->
<$set name=searchTerms tiddler=<<stateTid>> field=text>
<$list filter="[<searchTerms>minlength[3]limit[1]]" emptyMessage="Search text too short" variable=ignore>
<!-- Check input search term -->
<$list filter="[<searchTerms>regexp<pattern>]" emptyMessage=<<standardSearch>> >
 <<filterSearch>>
</$list>
</$list>
</$set>
</$reveal>
</$vars>
\end

<<combo-search>>


Question:
  1. what is the best regexp pattern here?
  2. how to improve the performance
--Mohammad

Mohammad

unread,
Dec 19, 2019, 2:07:23 AM12/19/19
to TiddlyWiki
A little better macro

\define standardSearch()
<$set name=searchFilter value="[all[tiddlers]!is[system]search:title,caption,text[$(searchTerms)$]]">
//<small>Standard search: <$count filter=<<searchFilter>> /> matches</small>//<br>
<$list filter=<<searchFilter>> >
<$link/><br>
</$list>
</$set>
\end

\define filterSearch()
//<small>Filter search: <$count filter=<<searchTerms>>/> matches</small>//<br><!--for debugging-->

<$list filter=<<searchTerms>> >
<$link/><br>
</$list>
\end

\define combo-search()
<$vars pattern="^\["
       stateTid="$:/temp/comboSearch">
 
<!--UI -->
combo search &nbsp;<$edit-text tiddler=<<stateTid>> tag=input/>  
<!-- show results if any-->
<$reveal state=<<stateTid>> type="nomatch" text=""><!--do not display when searchbox is empty-->
<$button class="tc-btn-invisible">
<$action-setfield $tiddler=<<stateTid>> $field="text" $value=""/>
{{$:/core/images/close-button}}
</$button><br>

<$set name=searchTerms tiddler=<<stateTid>> field=text>

<$list filter="[<searchTerms>trim[]minlength[3]limit[1]]" emptyMessage="Search text too short" variable=ignore>

<!-- Check input search term -->
<div class="tc-search-results">
<$list filter="[<searchTerms>trim[]regexp<pattern>]" emptyMessage=<<standardSearch>> >
 <<filterSearch>>
</$list>
</div>
</$list>
</$set>
</$reveal>
</$vars>
\end

<<combo-search>>

TonyM

unread,
Dec 19, 2019, 5:39:40 AM12/19/19
to TiddlyWiki
Mohammad

I have not tested your example yet but could you just test if the search string begins [ and use is as a filter instead?

perhaps not as a filter if /[ is the prefix remove / for an override?

I just created a number of different sesrches.

Tony

bimlas

unread,
Dec 19, 2019, 5:51:16 AM12/19/19
to TiddlyWiki
Another solution: https://bimlas.gitlab.io/demo/tw5/combined-search.html

Try to search for $:/ colour picker (system+shadow tiddlers) or [tag[$:/tags/Macro]] (filter) in the search bar!

If you don't want to override default search results, just rename the tiddler from $:/core/ui/DefaultSearchResultList to something else.

TonyM,

Put a space before [ to perform normal search instead of filter. This does not works in Mohammad's solution, but in mine.

A Gloom

unread,
Dec 19, 2019, 6:17:20 AM12/19/19
to TiddlyWiki
*head hits keyboard*

more to add to list of things to check out-- all looks really good but

just like Lucifer & Sinatra, I must first figure and do it myself-- habit that's really hard to kick

for performance, I think keeping with the default 3 character limit before getting results or using reg exp ^ (beiginning of string), \b (beginning of words), "exact" match-- all depending on how you want your search to be performed.  Definittely limit what fields to search (especially text) if possible.

Mohammad

unread,
Dec 19, 2019, 10:17:52 AM12/19/19
to TiddlyWiki
Hi Tony!
Seems this is an issue
 - in Tiddlywiki.com you can search as standard search fro a phrases like [tag[xx]] and it will search in text to find it!
 - here in combo search this will be interpreted as filter search!

I am thinking how to address this issue.

--Mohammad

Mohammad

unread,
Dec 19, 2019, 10:30:33 AM12/19/19
to TiddlyWiki
Hi A Gloom,
 Added the minlength!
Noted! 

Mohammad

unread,
Dec 19, 2019, 10:31:46 AM12/19/19
to TiddlyWiki
bimlas,
 Thanks you!
Yes, I use trim[] to remove the trailing blanks perhaps removing it to do the normal search

--Mohammad 

TonyM

unread,
Dec 20, 2019, 7:10:10 PM12/20/19
to TiddlyWiki
A Gloom (Can we have a more personal name?)
 

just like Lucifer & Sinatra, I must first figure and do it myself-- habit that's really hard to kick

I so agree with this !

Regards
Tony

Mohammad

unread,
Dec 20, 2019, 11:11:59 PM12/20/19
to TiddlyWiki
Hi Bimlas,
 I tried your combined searchbox and it is quite powerful!
It is a pity it was not announced here in community!


@David Gifford
This is a wiki for combined search

Good to add to toolmap as search tool


--Mohammad

TonyM

unread,
Dec 21, 2019, 2:07:28 AM12/21/19
to TiddlyWiki
Mohammad,

Just sharing in case there is a method you want to use.

Please find attached an in progress extended search of my own, using the tag $:/tags/SearchResults a few times

It appears below the standard search ( in tabs ).

Extended is something I would like to introduce to the standard distribution. For example edit the caption of 

$:/Manager

to read "Tiddler Manager" and 

$:/TagManager

to read "Tag Manager"

And they will appear as a result in the extended search if you search for manager.
It's a way of plugins and macros to include themself in the search outcomes without searching all system tiddlers

The extended search also searches for the search string in the keywords fieldname of any tiddler.

The Hashtags Search is a work in progress and has abended my wiki, the method there may also be used to search for keywords independently.

System is system tiddlers only and uses the caption if available (and not a transclusion)

Tags is for tag tiddlers only and uses the caption if available (and not a transclusion)


Regards
Tony
extended-search.bundle.json

Mohammad

unread,
Dec 21, 2019, 6:52:59 AM12/21/19
to TiddlyWiki
Hi Tony!
 Many thanks for these useful search tools!
 It seems there is potential to make very customized search boxes.

Cheers
Mohammad

A Gloom

unread,
Dec 21, 2019, 6:20:02 PM12/21/19
to TiddlyWiki
looks interesting, may be helpful in my pursuits (yorr work has always been helpful-- I have scoured PSaT for ideas before), but first must... : )

more personal name?  I don't know... back in the ether prehistory (time of local BBS & Telnet, there was a Gloom, when someone said let there be tcip, there was a Gloom,,, though there's no Gloom on social media... so there must be not person any longer-- just Gloom : P )

TonyM

unread,
Dec 21, 2019, 7:31:09 PM12/21/19
to TiddlyWiki
Gloom

Psat website or the tiddlywiki.psat.com.au has not had many updates but hopefully will soon.

Regards
Tony

TonyM

unread,
Dec 21, 2019, 7:37:56 PM12/21/19
to TiddlyWiki
Mohammad

In my examples the extended one is what I would like to propose to add to the default since it allows a system tiddler to appear in the standard search if it has a caption. You can add captions to the many tools you have shared and users can find them in the standard search.

I would like your view on this

Tony

A Gloom

unread,
Dec 21, 2019, 8:28:55 PM12/21/19
to TiddlyWiki

Psat website or the tiddlywiki.psat.com.au has not had many updates but hopefully will soon.

Regards


So where's all your coding secrets then?  >> <<

TonyM

unread,
Dec 21, 2019, 9:07:10 PM12/21/19
to TiddlyWiki
All here or in some off line WIkis, often half done. 

When I come up with a good idea, I test it and confirm it works, but do not yet polish it up and publish like others. If a question demands I will provide targeted info but this polishing takes time, especially since I always find a few ways to make it even better and these need work so I cant publish them.

Regards
Tony

Mohammad

unread,
Dec 22, 2019, 2:10:20 AM12/22/19
to TiddlyWiki
Tony!
 That's a nice trick to standard search box :-)
--Mohammad

Mohammad

unread,
Dec 22, 2019, 2:50:32 AM12/22/19
to TiddlyWiki
Reply all
Reply to author
Forward
0 new messages