Nice TWiki > TWiki > FormattedSearch (r1.7 vs. r1.8) TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
TWiki . { Welcome | Register | Changes | Topics | Index | Search | Go }
 <<O>>  Difference Topic FormattedSearch (r1.8 - 17 May 2002 - PeterThoeny?)
Deleted:
<
<

Nested Search

Search can be nested. For example, search for some topics, then form a new search for each topic found in the first search. The idea is to build the nested search string using a formatted search in the first search.

Here is an example. We want to search for topics, do a nested search with each hit, and show the result as nested bullets. Parameters like scope="text" regex="on" nosearch="on" nototal="on" are omitted for simplicity.

  • First search:
    • %SEARCH{ "freedom" format="   * $topic" }%
  • Second search. For each hit we want this search:
    • %SEARCH{ "(topic of first search)" format="      * $topic" }%
  • Now we nest the searches. We need to escape the second search, e.g. the first search will build a valid second search string:
    • %SEARCH{ "freedom" format="   * $topic: $n$percntSEARCH{ \"$topic\" format=\"      * $dollartopic" }$nop%\" }%

Note that we escape the second search so that it does not get evaluated by the first search:

  • $percnt to escape the leading percent of the second search
  • \" to escape the qouble quotes
  • $dollar to escape the $ of $topic
  • $nop to escape the }% sequence
Added:
>
>

Changed:
<
<

Write this:

>
>

Write this:

Changed:
<
<

To get this:

>
>

To get this:

Added:
>
>

Changed:
<
<

Write this in the Know web:

>
>

Write this in the Know web:

Changed:
<
<

To get this:

>
>

To get this:

Added:
>
>

Changed:
<
<

Write this:

>
>

Write this:

Changed:
<
<

To get this:

>
>

To get this:

Added:
>
>

Nested Search

Search can be nested. For example, search for some topics, then form a new search for each topic found in the first search. The idea is to build the nested search string using a formatted search in the first search.

Here is an example. Let's search for all topics that contain the word "culture" (first search), and let's find out where each topic found is linked from (second search).

  • First search:
    • %SEARCH{ "culture" format="   * $topic is referenced by: (list all references)" nosearch="on" nototal="on" }%
  • Second search. For each hit we want this search:
    • %SEARCH{ "(topic found in first search)" format="   $topic" nosearch="on" nototal="on" }%
  • Now let's nest the two. We need to escape the second search, e.g. the first search will build a valid second search string. Note that we escape the second search so that it does not get evaluated prematurely by the first search:
    • Use $percnt to escape the leading percent of the second search
    • Use \" to escape the double quotes
    • Use $dollar to escape the $ of $topic
    • Use $nop to escape the }% sequence

Write this:

%SEARCH{ "culture" format="   * $topic is referenced by:$n      * $percntSEARCH{ \"$topic\" format=\"   $dollartopic\" nosearch=\"on\" nototal=\"on\" }$nop%" nosearch="on" nototal="on" }%

To get this:


Topic FormattedSearch . { View | Diffs | r1.9 | > | r1.8 | > | r1.7 | More }
Revision r1.7 - 20 Apr 2002 - 02:37 GMT - PeterThoeny?
Revision r1.8 - 17 May 2002 - 06:57 GMT - PeterThoeny?
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.