Filtering multiple fields at once

136 views
Skip to first unread message

PWL

unread,
Oct 4, 2018, 3:30:15 PM10/4/18
to tiddl...@googlegroups.com
Hello all,  Don't know if this counts as a noob thing, but I am.

I have multiple tiddlers that all have 3 custom fields.  I am using the search function in the side bar to filter my tiddlers using said fields (works very well)  the problem I am having is that each filter lists every link so I have a list of all my tiddlers for each filter.  I have tried several different ways to correct this and broke the filter each time.  Here is the code. 

<$list filter="[[$:/temp/search]] +[minlength[2]]">
<<list-links "[has[intelligence]search:intelligence{$:/temp/search}]">>
<<list-links "[has[hd]search:hd{$:/temp/search}]">>
<<list-links "[has[climate_terrain]search:climate_terrain{$:/temp/search}]">>
</$list>

Here is how it renders.  Ideally I would like to have the search function built into my index page, however I am happy with a search tab like I have now if it functions well.  A little bit of context... I have 4500+ entries to make, that is 13 500 links if I keep going that way, far to many to be practical.  Please somebody help me with this.  I think I may be reaching to high here.  I need to be able to search each field individually.  Is there a way to not have the links listed, but still display the results?

On a personal note.... I know there are a lot of programmers and the like in this group, Although I do greatly appreciate your help, please do not post code assuming I know how to make it work.  I can tell you now; I will not know how to make it work; I will not know where to put it, I will not know how to integrate it into what I already have.  Talk to me like a 2 year old.  Assume I can barely manage to turn my computer on.  This will reduce the number of follow up questions I have and the frustration levels.   Thank you.

search capture.jpg


Mark S.

unread,
Oct 4, 2018, 6:47:30 PM10/4/18
to TiddlyWiki
Since you're searching on 3 things, you need 3 search fields. This means you'll need custom search input boxes. Put the following in a tiddler (possibly in your INDEX tiddler):

Intelligence: <$edit-text tiddler="$:/temp/intelligence" tag="input" size=10 placeholder="Intel"/> <br/>


Also make an empty tiddler with the title $:/temp/intelligence. Hopefully you can see how this works. You need a separate tiddler for each aspect that you want to search. Copy the line and "intelligence" (and "Intel") as appropriate for each dimension. So you might end up with:

Intelligence: <$edit-text tiddler="$:/temp/intelligence" tag="input" size=10 placeholder="Intel"/> <br/>
Climate/terrain: <$edit-text tiddler="$:/temp/climate_terrain" tag="input" size=10 placeholder="Cli/Ter"/> <br/>
HD: <$edit-text tiddler="$:/temp/hd" tag="input" size=10 placeholder="HD"/> <br/>


And now your search (without the complication of minimum length) might look like:

<<list-links "[has[intelligence]search:intelligence{$:/temp/intelligence}has[climate_terrain]search:climate_terrain{$:/temp/climate_terrain}has[hd]search:hd{$:/temp/hd}]">>

This will match exclusively for all 3 items. That is, all 3 items have to match before any search results show. Note that an empty search field will probably be seen as "all matches" so you may see an all-up listing at first (because we've stripped out the minlength detection).

Check my work for spelling and name consistencies -- I haven't tested any of this. Writing up stuff takes time and testing takes even more when you don't have a data source handy.

Note that for fields that have simple, direct values (like "15") then you can use filter items like "category[15]" which is more precise than using search. But if your field has multiple values (like "Average (10-12)") then you need to use something like the "search" operator.

Good luck!
-- Mark

PWL

unread,
Oct 4, 2018, 7:14:46 PM10/4/18
to TiddlyWiki
That is a great start Mark.  I guess I wasn't clear enough.  I need to be able to search each field individually.  I am really not concerned with having a match in all three at once, just which ever one I am looking for at the time.  If you would like access to my data I can send it too you.  or post a cap of the tiddler code here.

Mark S.

unread,
Oct 4, 2018, 11:42:23 PM10/4/18
to TiddlyWiki
So, basically you want to select the search. TiddlyWiki gives you a way to make those kind of choices. It's the select widget.

Here we're back to using the search box on the side. Paste this into INDEX or wherever you want:

<$select tiddler="$:/temp/searchfilter" default="Choose">
<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>

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

The "macrocall" is invoking the list-links macro in a way that allows us to pass in the results of the selection.

The selection creates a drop-down list. You can pick whatever search you want and that's how the contents of the search box will be used. You can hopefully see how the filter for each option choice is made. You can copy the existing options and tweak them to match other search criteria as you add fields to your data and searches.

As always make backups!

HTH
-- Mark

PWL

unread,
Oct 5, 2018, 3:18:45 AM10/5/18
to TiddlyWiki
Thank you so much Mark, that worked perfectly!  You've been a great help.  Again thank you.
Reply all
Reply to author
Forward
0 new messages