Searching in other fields

Hi, I have big problem. We creating knowledgebase about some architectural items. I have tiddlers with some fields (description, obligation, etc.). Record of obligation I generate using transclusion by self-made little template drawing it from tiddler´s fields.

And now my problem: Standard search editbox on TW searches only in title and text fields, so it cannot find any item, because their text fields are drawen by transclusion of template from fields. Is there any way to modify edit box to search for another fields too? I want complex search by text, description, obligation fields at once.

Many thanks for ideas.

The standard first approach is create a new search result visualisation

Create a tiddler tagged $:/tags/SearchResults, with a caption field set, containing;

\define searchResults()
<$set name="resultCount" value="""<$count filter="[!is[system]search:-text{$(searchTiddler)$}]"/>""">

{{$:/language/Search/Matches}}

</$set>
<<timeline subfilter:"!is[system]search:-text{$(searchTiddler)$}">>
\end
<<searchResults>>
  • Notice how the use of the search operator has being modified from the example content to search all but thew text field
  • This will provide an additional tab under the search results from the sidebar, if in the menu or using the advanced search > Standard tab
  • The above uses the timeline macro

This following example lists todo items not done, and not using the timeline macro.

\define searchResults()
<$set name="resultCount" value="""<$count filter="[tag[todo]!tag[done]search:title{$(searchTiddler)$}] [tag[reference]!tag[done]search:title{$(searchTiddler)$}]"/>""">

Search todo not done title only<br>
{{$:/language/Search/Matches}}

</$set>
<$list filter="[tag[todo]!tag[done]search:title{$(searchTiddler)$}] [tag[reference]!tag[done]search:title{$(searchTiddler)$}] +[sort[]]">

</$list>
<!--<timeline subfilter:"!is[system]tag[Project]!tag[done]!search:title,text,description,keyword{$(searchTiddler)$}">-->
\end

<<searchResults>>

you could have a look at my field-search plugin

Many thanks for both usefull method, but… Users are lazy and best method for me is to customise default search behaviour. Yes, we as power users can quickly switch to another tab on search results, but normal users wont it.

The solution I gave you creates a new search tab, under the standard search. So it is not like it will not be noticed, but I understand you want these alternative fields searched. You can modify primary search directly, although that is somewhat different to achieve to my prior instructions.

Here is what I found with a little reverse engineering of the standard search;

  • The default search results are generated here $:/core/ui/DefaultSearchResultList
  • The normal behaviour is;
    • one search based on the title only, in the field first-search-filter [!is[system]search: title<userInput>sort[title]limit[250]]
    • Then a search based on the text field second-search-filter [!is[system]search<userInput>sort[title]limit[250]]
    • This preferences search results where the search string is in the title, then see the search Operator which defaults to
      • field list: a comma delimited list of field names to restrict the search, defaults to tags, text and title if blank.

So there are a few different ways to handle this adjustment.

  • For example use a second-search-filter that searches all fields
    • [!is[system]search:*<userInput>sort[title]limit[250]]
  • Or just your extra fields Plus the normal ones
    • [!is[system]search:title,tags,text,description,obligation<userInput>sort[title]limit[250]]

Normally I would hide the default behaviour and display a modified search in the sidebar but the standard sidebar search is a little convoluted to do this.