r2 - 10 Jul 2004 - 06:34:06 - PeterThoenyYou are here: TWiki >  Codev Web > MoreNestedSearchLevels
Tags:
, create new tag

Implemented: Increase levels of nested search

FormattedSearch supports nesting up to 2 levels. This change allows nesting up to 16 levels. This is needed for complex queries where you have different types of TWikiForms records and want to pull a field of record, who's topic name is in a field of another record, who's...

Updated doc:

Note: Nested search can be slow, especially if you nest more then 3 times. Nesting is limited to 16 levels. For each new nesting level you need to "escape the escapes", e.g. write $dollarpercntSEARCH{ for level three, $dollardollarpercntSEARCH{ for level four, etc.

Change in twiki/lib/TWiki.pm:

diff -c bu1 TWiki.pm
*** bu1/TWiki.pm        2004-04-30 14:23:19.000000000 -0700
--- TWiki.pm    2004-07-09 13:41:29.000000000 -0700
***************
*** 2108,2115 ****
      $_[0] =~ s/%STOPINCLUDE%//g;
      $_[0] =~ s/%SECTION{(.*?)}%//g;
      $_[0] =~ s/%ENDSECTION%//g;
!     $_[0] =~ s/%SEARCH{(.*?)}%/&handleSearchWeb($1)/ge; # can be nested
!     $_[0] =~ s/%SEARCH{(.*?)}%/&handleSearchWeb($1)/ge if( $_[0] =~ /%SEARCH/o );
      $_[0] =~ s/%METASEARCH{(.*?)}%/&handleMetaSearch($1)/ge;

  }
--- 2108,2117 ----
      $_[0] =~ s/%STOPINCLUDE%//g;
      $_[0] =~ s/%SECTION{(.*?)}%//g;
      $_[0] =~ s/%ENDSECTION%//g;
!     my $ok = 16; # SEARCH may be nested up to 16 times
!     TRY: while( $_[0] =~ s/%SEARCH{(.*?)}%/&handleSearchWeb($1)/ge ) {
!         last TRY unless( --$ok );
!     }
      $_[0] =~ s/%METASEARCH{(.*?)}%/&handleMetaSearch($1)/ge;

  }

Benchmarks

Topic Before After change
TWiki.WelcomeGuest 0.50 0.51
TWiki.WikiWord 0.49 0.50
TWiki.FormattedSearch 1.28 1.29

-- PeterThoeny - 09 Jul 2004

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback SourceForge.net Logo