Tags:
create new tag
, view all tags

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 | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2004-07-10 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.