Searches

171 views
Skip to first unread message

PWL

unread,
Dec 10, 2019, 4:49:26 PM12/10/19
to TiddlyWiki
Hello all,

I was wondering if there are any other search options for Tiddly.  Currently I am using the sidebar search, but I am having some issues with it.  I am using it to search fields, but I am finding that it does not like individual characters such as '1' or 'A'.  when I try to search a single character it returns every entry with that particular character in it even if it is part of a series or another number.  I want to search for the number 2 and I get returns that include 2, 12, 20, 22. is there a way to fix this?  I thought it might be in the set up of the fields but I didn't find anything.  Further more I am finding that the more entries I make the less efficient the side bar search is, if there is another option I am open to suggestions.

Here is the code I am using.

Search <$select tiddler="$:/temp/searchfilter" default="Choose" tag="input">
<option value="Choose">-Choose one-</option>
<option value="[has[intelligence]search:intelligence{$:/temp/search}]">Intelligence</option>
<option value="[has[climate_terrain]search:climate_terrain{$:/temp/search}]">Climate/Terrain</option>
<option value="[has[hd]search:hd{$:/temp/search}]">HD</option>
</$select>
<$edit-text tiddler="$:/temp/search" tag="input" />

<$macrocall $name="list-links" filter={{$:/temp/searchfilter}} />
@@.fourcolumns
<div class="tc-table-of-contents">
<<toc-selective-expandable 'INDEX' sort[title]>>
@@

Oh and please speak to me like this is the first time I have even seen a computer.  I AM IN NO WAY A PROGRAMMER! I have a hard time understanding anything beyond BASIC little own this stuff.

Thanks for your help.

Eric Shulman

unread,
Dec 10, 2019, 6:49:06 PM12/10/19
to TiddlyWiki
On Tuesday, December 10, 2019 at 1:49:26 PM UTC-8, PWL wrote:
I am finding that the more entries I make the less efficient the side bar search is, if there is another option I am open to suggestions. 

Search <$select tiddler="$:/temp/searchfilter" default="Choose" tag="input">

<option value="Choose">-Choose one-</option>
<option value="[has[intelligence]search:intelligence{$:/temp/search}]">Intelligence</option>
<option value="[has[climate_terrain]search:climate_terrain{$:/
temp/search}]">Climate/Terrain</option>
<option value="
[has[hd]search:hd{$:/temp/search}]">HD</option>
</$select>
<$edit-text tiddler="
$:/temp/search" tag="input" />

<$macrocall $name="
list-links" filter={{$:/temp/searchfilter}} />
@@.fourcolumns
<div class="
tc-table-of-contents">
<<toc-selective-expandable 'INDEX' sort[title]>>
@@
 
There is one thing you could try that *might* save some computing cycles:

You are basically doing your own search processing via the list-links macro filter.
However, since you are using "$:/temp/search" to hold your search input text,
it is also triggering the sidebar search, which means that the same work is being done twice!

To avoid this, just change the search input from "$:/temp/search" to something else, like "$:/temp/mysearch".
(make sure to also change all your references to it in the $select option entries.)

I can't say for sure that this will make a significant difference, but it might help, even if only a little bit.

let me know how it goes...

-e

PWL

unread,
Dec 10, 2019, 7:03:37 PM12/10/19
to TiddlyWiki
That did stop the side bar from doing the same search.  Thank you.  Looks much cleaner now.  Now I have to figure out how to make it search for single character inputs.

Mark S.

unread,
Dec 10, 2019, 7:11:33 PM12/10/19
to TiddlyWiki
For the 2nd part, wrap the lookup macro with a list that uses a minlength operator:

<$list filter="[{$:/temp/mysearch}minlength[2]limit[1]]" emptyMessage="Input length too short">

<$macrocall $name="list-links" filter={{$:/temp/searchfilter}} />
@@.fourcolumns
<div class="tc-table-of-contents">
<<toc-selective-expandable 'INDEX' sort[title]>>
</div>
@@
</$list>

Notice that I added in </div> . It wasn't there in your example code. All tags must match in TW5 code. I also changed the search to $:/temp/mysearch , so be sure to change that to whatever you decided to use.

You can change the number in minlength[2] to minlength[3] or whatever works for you.

-- Mark

Eric Shulman

unread,
Dec 10, 2019, 7:43:00 PM12/10/19
to TiddlyWiki
On Tuesday, December 10, 2019 at 4:11:33 PM UTC-8, Mark S. wrote:
For the 2nd part, wrap the lookup macro with a list that uses a minlength operator:

I don't think that's what he is trying to achieve... he said he *wants* to search for single character input, but only get results for which that character occurs in isolation:

in his initial question, PWL wrote:
when I try to search a single character it returns every entry with that particular character in it even if it is part of a series or another number.  I want to search for the number 2 and I get returns that include 2, 12, 20, 22. is there a way to fix this?

One possibility is to use the more strict "literal" search flag that would require an exact match of the input. Like this:
<option value="[has[intelligence]search:intelligence:literal{$:/temp/search}]">Intelligence</option>
<option value="[has[climate_terrain]search:climate_terrain:literal{$:/temp/search}]">Climate/Terrain</option>
<option value="[has[hd]search:hd:literal{$:/temp/search}]">HD</option>

Then, when entering the search input, he could type in the number, surrounded by whitespace (e.g., " 2 ", without the quotes)

That *should* force the search to match only the number 2 as a separate "word" in the text, preventing it from matching "12", "20", or "22".

Of course, if the number is at the start or end of the text to match, he would need to type "2 " or " 2", respectively.

It's not a perfect solution, but it might allow him to work around some of the specific use-cases he needs.

-e





 

 

A Gloom

unread,
Dec 10, 2019, 8:16:22 PM12/10/19
to tiddl...@googlegroups.com
Eric pretty much got the answer & showed you you can make seperate search/bar other than the sidebar search

this for when you get more comfortable with the code-- replace the search operator (search:field) with the regexp operator where you can control what how the search is preformed

paste this into a new tiddler at https://tiddlywiki.com/

search

<$list filter="[!is[system]search:title[reg]]">

</$list>

plain regexp

<$list filter="[!is[system]regexp:title[(?i)reg]]">

</$list>

regexp first letter of title (or field) "^"

<$list filter="[!is[system]regexp:title[(?i)^reg]]">

</$list>

regexp first letter of any word in title (or field) "\b"

<$list filter="[!is[system]regexp:title[(?i)\breg]]">

</$list>

attached is a regexp search bar for search data tiddlers if you want to play with it


regex select search.tid

PWL

unread,
Dec 11, 2019, 7:07:36 PM12/11/19
to TiddlyWiki
That is exactly what I am looking for.  And now I am staring at the code trying to figure out how to make it work with what I have. I suck at this crap.  Probably why I became an electronics Tech, not technologist.  Anyway here is what my code looks like now.

Search by <$select tiddler="$:/temp/searchfilter" default="Choose" tag="input">

<option value="Choose">-Choose one-</option>
<option value="[has[intelligence]search:intelligence{$:/temp/mysearch}]">Intelligence</option>
<option value="[has[climate_terrain]search:climate_terrain{$:/temp/mysearch}]">Climate/Terrain</option>
<option value="[has[hd]search:hd{$:/temp/mysearch}]">HD</option>
</$select>
<$edit-text tiddler="$:/temp/mysearch" tag="input" />


<$macrocall $name="list-links" filter={{$:/temp/searchfilter}} />
@@.fourcolumns
<div class="tc-table-of-contents">
@@

PWL

unread,
Dec 11, 2019, 7:20:22 PM12/11/19
to TiddlyWiki
I tried that code... Main interest is for the HD field.  Didn't work.  Don't know what I did wrong.  I copied the exact line into my code but I go nothing.  It stopped giving any results at all... blank page.

Eric Shulman

unread,
Dec 11, 2019, 7:47:15 PM12/11/19
to TiddlyWiki
On Wednesday, December 11, 2019 at 4:20:22 PM UTC-8, PWL wrote:
I tried that code... Main interest is for the HD field.  Didn't work.  Don't know what I did wrong.  I copied the exact line into my code but I go nothing.  It stopped giving any results at all... blank page.

The example code I posted (which you copied "exactly") was still using "$:/temp/search"... change it to "$:/temp/mysearch" and it should work again.

-e

PWL

unread,
Dec 12, 2019, 4:34:10 PM12/12/19
to TiddlyWiki
Okay fixed that.  Unfortunately it didn't work.  I tried surrounding it with spaces too.  Still getting the same results, search one and get 1,10, 11, 12 etc.

Mark S.

unread,
Dec 12, 2019, 5:21:58 PM12/12/19
to TiddlyWiki

Try modifying the search filter so it looks for the literal string:

That is, change

search:hd

to

search:hd:literal

Eric Shulman

unread,
Dec 12, 2019, 6:36:07 PM12/12/19
to TiddlyWiki
On Thursday, December 12, 2019 at 2:21:58 PM UTC-8, Mark S. wrote:
Try modifying the search filter so it looks for the literal string:
That is, change 
search:hd
to
search:hd:literal

That is exactly what I already suggested: adding the "literal" flag to the search filters, and then entering spaces surrounding the target value in the input field (e.g., " 2 ").  He said it didn't work, but I'm not sure why it didn't.

-e
 

A Gloom

unread,
Dec 12, 2019, 6:42:07 PM12/12/19
to TiddlyWiki
the literal prefix won't work for what OP wants

testing with 2 tiddlers with the 3 fields, one tiddler all fields set at 1, the other set at 12...

search for "1" brings up both, search for "12" brings up the 2nd tiddler

for exact matches of even a single character, this regexp works

<$list filter="[has[intelligence]regexp:intelligence[\b1\b]]"></$list>

for a search for "1",it brings up just the 1st tiddler and not the second

but it breaks the select value when i insert the regexp

<option value="[has[intelligence]regexp:intelligence[\b{$:/temp/search}\b]]">Intelligence</option>

the transclusion fails, the value that gets passed to the macrocall ends up "[has[intelligence]regexp:intelligence[\b{$:/temp/search2}\b]]"

Mark S.

unread,
Dec 12, 2019, 10:06:21 PM12/12/19
to TiddlyWiki
Because "literal" doesn't work, a lot more code is needed.

Make a backup of your work. Here's my version, which I tested with some simple data. I may have lost the formatting you had with @@, so you may need to put that back in. Basically what the following does is use a whole separate routine for the special case where you are doing an HD search.

Search by <$select tiddler="$:/temp/searchfilter" default="Choose" tag="input">
<option value="Choose">-Choose one-</option>
<option value="[has[intelligence]search:intelligence{$:/temp/mysearch}]">Intelligence</option>
<option value="[has[climate_terrain]search:climate_terrain{$:/
temp/mysearch}]
">Climate/Terrain</option>
<option value="
HD%%HD">HD</option>
</$select>
<$edit-text tiddler="
$:/temp/mysearch" tag="input" /><br/>


<$vars  hdf1="
[has[hd]regexp:hd[\b" hdf2="\b]]" >

<$reveal text={{$:/temp/searchfilter}} default="
HD%%HD" type="match">

<$wikify text={{{ [<hdf1>addsuffix{$:/temp/mysearch}addsuffix<hdf2>] }}} name="
hdfilter">

<$macrocall $name="
list-links" filter=<<hdfilter>> />


</$wikify>

</$reveal>

<$reveal text={{$:/temp/searchfilter}} default="
HD%%HD" type="nomatch">

<$macrocall $name="
list-links" filter={{$:/temp/searchfilter}} />

</$reveal>

</$vars>





On Thursday, December 12, 2019 at 1:34:10 PM UTC-8, PWL wrote:

A Gloom

unread,
Dec 12, 2019, 11:22:13 PM12/12/19
to TiddlyWiki
Nice work Mark-- will be studying it...

Hopefully that will work for PWL

is literal not working in this use case?  It will find the literal search string/term, wether it's part of a string/value as well as a separate/independent value/string?

Mark S.

unread,
Dec 12, 2019, 11:26:41 PM12/12/19
to TiddlyWiki
I'm thinking "literal" might be broken, or maybe we're interpreting it too .... wait for it ... literally.

A Gloom

unread,
Dec 13, 2019, 12:41:41 AM12/13/19
to TiddlyWiki
I'm thinking "literal" might be broken, or maybe we're interpreting it too .... wait for it ... literally.

: )  coder humor

PMario

unread,
Dec 13, 2019, 4:13:59 AM12/13/19
to TiddlyWiki
Hi PWL,

Not a 100% fit, but my field-search plugin may be of interest. See the GG thread. It also contains a video link.

have fun!
mario

PMario

unread,
Dec 13, 2019, 4:14:28 AM12/13/19
to TiddlyWiki

TiddlyTweeter

unread,
Dec 13, 2019, 5:19:16 AM12/13/19
to TiddlyWiki
Ciao Mark S.

Always interesting to read you at the edge where you get something to work!

Again, this thread shows there is a broader comprehension issue compounded by some unclarity whether its docs or brokenness at base.

Side thoughts
TT

Mark S. wrote:
I'm thinking "literal" might be broken, or maybe we're interpreting it too .... wait for it ... literally.

A Gloom wrote:

PWL

unread,
Dec 15, 2019, 9:29:07 AM12/15/19
to TiddlyWiki
Hey all,

With a few minor changes to my fields Mark's code worked.  Thank you all for your help. :)
Reply all
Reply to author
Forward
0 new messages