• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.
same as cairo, so i'm marking this as an enhancement

WN

Probably good to introduce a new parameter toplimit (or the like) to limit the total number of hits. This is for compatibility.

-- PTh

This would be a real treat. Have had a suggestions from users to use some top space (WebTopBar) for a "last 5 changed topics, globally"-style info area, but this is not easy to implement using current search.

-- SP

ThisIsEasy CC


I hope you are right, CC smile

Looking at the code, naively I'd probably jump in around line 949 in Search.pm, where all webs has been searched. - Unfortunately, everything is rendered more or less up at this point, so I guess the only simple opportunity left (without a major refactor) is simply regexp'ing the $searchresult for $separator, taking first $toplimit matches and cutting the rest.

In cases where the search result contains $separators on it's own, this will of course not work reliably, but I'm having problems imagining any real life searches where this would actually be a problem.

Other solutions, or will this work? I.e. something like:

Index: lib/TWiki/Search.pm
===================================================================
--- lib/TWiki/Search.pm   (revision 8988)
+++ lib/TWiki/Search.pm   (working copy)
@@ -381,6 +381,7 @@
     my $header =        $params{header} || '';
     my $inline =        $params{inline};
     my $limit =         $params{limit} || '';
+    my $toplimit =      $params{toplimit};
     my $doMultiple =    TWiki::isTrue( $params{multiple} );
     my $nonoise =       TWiki::isTrue( $params{nonoise} );
     my $noEmpty =       TWiki::isTrue( $params{noempty}, $nonoise );
@@ -947,6 +948,12 @@
         return '' if ( $ntopics == 0 && $zeroResults );
     }
 
+    # if toplimit is set, cut down number of searchresults
+    if ( defined $toplimit && $toplimit =~ /(^\d+$)/o && $noTotal ) {
+        my $sep = $separator || "\n";
+        $searchResult =~ s/^((.*?$sep){0,$toplimit}).*$/$1/s;
+    }
+    
     if( $format  && ! $finalTerm ) {
         if( $separator ) {
             $searchResult =~ s/$separator$//s;  # remove separator at end
Index: data/TWiki/VarSEARCH.txt
===================================================================
--- data/TWiki/VarSEARCH.txt   (revision 8988)
+++ data/TWiki/VarSEARCH.txt   (working copy)
@@ -1,4 +1,4 @@
-%META:TOPICINFO{author="TWikiContributor" date="1111929255" format="1.2" version="$Rev$"}%
+%META:TOPICINFO{author="SteffenPoulsen" date="1141253089" format="1.1" version="1.2"}%
 %META:TOPICPARENT{name="TWikiVariables"}%
 #VarSEARCH
 
@@ -15,7 +15,8 @@
      | =type="keyword"= <br /> =type="literal"= <br /> =type="regex"= | Do a keyword search like =soap "web service" -shampoo=; a literal search like =web service=; or RegularExpression search like =soap;web service;!shampoo= | =%<nop>SEARCHVAR- DEFAULTTYPE%= [[TWikiPreferences][preferences]] setting (%SEARCHVARDEFAULTTYPE%) |
      | =scope="topic"= <br /> =scope="text"= <br /> =scope="all"= | Search topic name (title); the text (body) of topic; or all (both) | ="text"= |
      | =order="topic"= <br /> =order="created"= <br />  =order="modified"= <br /> =order="editby"= <br /> =order=<br />&nbsp;"formfield(name)"= | Sort the results of search by the topic names, topic creation time, last modified time, last editor, or named field of TWikiForms. The sorting is done web by web; if you want to sort across webs, create a [[FormattedSearch][formatted]] table and sort it with TablePlugin's initsort. Note that dates are sorted most recent date *last* (i.e at the bottom of the table). | Sort by topic name |
-     | =limit="all"= <br /> =limit="16"= | Limit the number of results returned. This is done after sorting if =order= is specified | All results |
+     | =limit="all"= <br /> =limit="16"= | Limit the number of results returned from a single web. This is done after sorting if =order= is specified | All results |
+     | =toplimit="20"= | Limit the number of total number of results returned. This is done after sorting if =order= is specified. =toplimit= will only work if =nototal= is set to "on". | All results |
      | =date="..."= | limits the results to those pages with latest edit time in the given TimeInterval.  | All results |
      | =reverse="on"= | Reverse the direction of the search | Ascending search |
      | =casesensitive="on"= | Case sensitive search | Ignore case |
@@ -37,4 +38,3 @@
    * Example with format: =%<nop>SEARCH{"FAQ" scope="topic" nosearch="on" nototal="on" header="| *Topic: * | *Summary: * |" format="<nop>| $topic | $summary |"%= _(displays results in a table with header - [[FormattedSearch][details]])_
    * %H% Hint: If the TWiki:Plugins.TablePlugin is installed, you may set a =%<nop>TABLE{}%= variable just before the =%<nop>SEARCH{}%= to alter the output of a search.  Example: =%<nop>TABLE{ tablewidth="90%" }%=
    * Related: [[#VarMETASEARCH][METASEARCH]], [[#VarTOPICLIST][TOPICLIST]], [[#VarWEBLIST][WEBLIST]], FormattedSearch

-- SP

Whooops, completely missed the fact that topics are not globally sorted in $searchResult, but only sorted "per web". This means giving up on the easy part for me.

-- SP

This topic was lost from the lists due to not having a codebase field. Rediscovered 3/2/07.

CC

No spec change please. New paramter is ok.

-- PTh

I would find limitall a more intuitive name, alongside limitweb, while limit is maintained for compatibility.

-- TWiki:Main.ArthurClemens - 03 Feb 2007

Sounds like it's just waiting for an implementor. Set status accordingly.

CC

new limitall and limitweb, keeping limit as undocumented feature sounds like a plan.

-- TWiki:Main.PeterThoeny - 05 Feb 2007

ItemTemplate
Summary SEARCH limit parameter applies to each web/subweb, not total number of matches
ReportedBy TWiki:Main.WillNorris
Codebase

SVN Range

AppliesTo Engine
Component

Priority Enhancement
CurrentState Confirmed
WaitingFor Someone to do it
Checkins

TargetRelease major
ReleasedIn

Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r12 - 2007-02-05 - PeterThoeny
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback