Can a SEARCH take another SEARCH's output as input? How to search all webs and subwebs, while excluding subwebs of a particular web

Until Tasks.Item8893 is resolved, the excludeweb parameter of VarSEARCH only excludes the web specified; its subwebs are still candidates for any search result.

For example, consider the following search:

%SEARCH{
  "name='WebHome'"
  type="query"
  web="all"
  recurse="on"
  nonoise="on"
  format="   * [[$web.$topic][$topic]]"
}%

Test:

Let's exclude Extensions web and all its subwebs. Sadly, this won't work, due to an open bug Tasks.Item8893:
%SEARCH{
  "name='WebHome'"
  type="query"
  web="all,-Extensions"
  recurse="on"
  nonoise="on"
  format="   * [[$web.$topic][$topic]]"
}%

So, let's try nesting a different SEARCH inside the outer SEARCH:
%SEARCH{
  "name='WebHome'"
  type="query"
  web="all,%SEARCH{
    "1"
    type="query"
    recurse="on"
    web="Extensions"
    topic="%WEBPREFSTOPIC%"
    nonoise="on"
    format="-$web"
    separator=", "
  }%"
  recurse="on"
  nonoise="on"
  format="   * [[$web.$topic][$topic]]"
}%

Test:

How it works

Refer to the description of inside-out, left-to-right macro expansion documentation: the inner SEARCH expanded first, which was:
%SEARCH{
    "1"
    type="query"
    recurse="on"
    web="Extensions"
    topic="%WEBPREFSTOPIC%"
    nonoise="on"
    format="-$web"
    separator=", "
  }%

Result: -Extensions, -Extensions/Archived, -Extensions/Testing

And so the outer SEARCH actually saw this, prior to expansion:
   * [[About.WebHome][WebHome]]
   * [[Community.WebHome][WebHome]]
   * [[Community/Developers.WebHome][WebHome]]
   * [[Development.WebHome][WebHome]]
   * [[Download.WebHome][WebHome]]
   * [[Home.WebHome][WebHome]]
   * [[Main.WebHome][WebHome]]
   * [[Sandbox.WebHome][WebHome]]
   * [[Support.WebHome][WebHome]]
   * [[Support/ClientSupport.WebHome][WebHome]]
   * [[Support/Question922.WebHome][WebHome]]
   * [[System.WebHome][WebHome]]
   * [[Tasks.WebHome][WebHome]]
   * [[Tasks/Testcases.WebHome][WebHome]]
   * [[Trash/MiguelSandbox.WebHome][WebHome]]
   * [[Trash/NC.WebHome][WebHome]]
   * [[Trash/PoojaBedur.WebHome][WebHome]]
   * [[Trash/StefanKrüger.WebHome][WebHome]]
   * [[Trash/Subweb.WebHome][WebHome]]

See also

Support.FAQForm edit

TopicClassification FrequentlyAskedQuestion
Subject Search
Topic Summary Example of exploiting "inside-out, left-to-right" macro expansion behaviour to exclude a web (and its subwebs) from a SEARCH using an inner (nested) SEARCH
Extension
Interested Parties PaulHarvey
Related Topics FormattedSearch#InsideOutLeftToRight, VarSEARCH, Tasks.Item8893
Topic revision: r4 - 27 Dec 2011, ArthurClemens
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy