r9 - 20 Jan 2004 - 07:31:01 - PeterThoenyYou are here: TWiki >  Codev Web > SearchScopeForTopicAndText
Tags:
, create new tag

Implemented: New scope=all search parameter to search in topic name and topic text at the same time

As documented in TWikiVariables, search currently supports scope="topic" (to search topic names) and scope="text" (to search in text body). The new scope="all" switch supports a search in topic names AND text body at the same time. The default scope remains "text" to keep %SEARCH{}% compatible.

SearchTopicNameAndTopicText is related but different, it allows to search for text in the text body on a limited number of topics.

Contributors:
-- PeterThoeny - 03 Jan 2004

Below content is refactored out of SearchSuggestion and SearchDoesNotWorkAsExpected.

-- PeterThoeny - 11 Oct 2003

I also had a request that the search will search in both topics and text, so I made a very simple modification that seems to be working fine. I made it the deault so either don't use the scope variable or use scope=all instead of scope=topic or scope=text . I'm kinda new at Perl - so please let me know if there is a better way of doing this.

I'm using the Dec 2000 code. The change is in wikisearch.pm.
I changed:

   if( $theScope eq "topic" ) {
        $cmd = "$wiki::lsCmd *.txt | %GREP% %SWITCHES% '$theSearchVal'";
    } else {
        $cmd = "%GREP% %SWITCHES% -l '$theSearchVal' *.txt";
    }
into
    if( $theScope eq "topic" ) {
        $cmd = "$wiki::lsCmd *.txt | %GREP% %SWITCHES% '$theSearchVal'";
    } elsif ( $theScope eq "text") {

        $cmd = "%GREP% %SWITCHES% -l '$theSearchVal' *.txt";
    } else {
        $cmd = "$wiki::lsCmd *.txt | %GREP% %SWITCHES% '$theSearchVal' ; %GREP% %SWITCHES% -l '$theSearchVal' *.txt";
    }
which works, but you can get the same Topic twice so I changed:
foreach( @tmpList ) {
    $tempVal = $_;
    # make topic unique
    if( $tempVal ne $lastTopic ) {
        push @topicList, $tempVal;
    }
}
into
foreach( sort @tmpList ) {
    $tempVal = $_;
    # make topic unique
    if( $tempVal ne $lastTopic ) {
        push @topicList, $tempVal;
        $lastTopic = $tempVal;
    }
}
The only thing I didn't understand is how #make topic unique worked before I added the line $lastTopic = $tempVal;

-- OphirPrusak - 25 Jul 2001

I've implemented OphirPrusak's code on the latest TWikiRelease01Feb2003 and created a Patch. It took a bit of working out where the code have chnaged from the 2000 release, and the having to put global replaces on the %TOKEN% and %FILES% serach and replaces troubled me for a while. I think the reason the #make topic unique was working was possably because with topic or text searches there would never be duplicates.

-- SamHasler - 07 Feb 2003

I think OphirPrusak and my comments and the patch would be better placed in a topic named SearchTopicAndText? . I could cut and paste the comments but I couldn't move the attachment. Strangly, when I tried to move the attachment it said "You do not have permission to rename topic SearchSuggestion.", so could someone with permission do it? Or should I just hide it and re-attach it to the new topic?

-- SamHasler - 13 Feb 2003

As well as the patch I've put a search box on the view page that has the following in the form to take advantage of the extra option:

<input type="hidden" name="scope" value="all" />
I haven't yet (but probably should) add an extra radio button to our WebSearch page.

-- SamHasler - 06 Jun 2003

One solution is to edit %TWIKIWEB%.WebSearch and change value="text" to value="all" :

<input type="radio" name="scope" value="all" checked="checked" /> Topic text (body) and titles

(the "all" parameter is described by PeterThoeny on the SearchSuggestion page.)

-- MattWilkie - 06 Feb 2003

The "all" parameter was only a suggested solution. However I've just attached a patch to SearchSuggestion to implement it.

-- SamHasler - 07 Feb 2003

Above discussion is refactored out from SearchSuggestion and SearchDoesNotWorkAsExpected.

-- PeterThoeny - 11 Oct 2003

I am currently working on this. At the same time I am implementing an InvertedSearchFeature, this is in preparation of KeywordSearchWithImplicitAnd.

I could not use Sam's patch for two reasons: Search.pm changed considerably and and search needs to work properly with AND search (";" separator).

-- PeterThoeny - 03 Jan 2004

This is in TWikiAlphaRelease and TWiki.org since 03 Jan 2004.

TWikiVariables, SearchHelp and WebSearch are updated.

-- PeterThoeny - 18 Jan 2004

Does 'regex = "on" ' still work? I guess it does as the WebRss works with it, but this is removed from TWikiVariables. Deprecated?

-- ArthurClemens - 19 Jan 2004

Yes, it works and is undocumented, as indicated in KeywordSearchWithImplicitAnd. From now on use type="regex" parameter.

-- PeterThoeny - 19 Jan 2004

Topic attachments
I Attachment Action Size Date Who Comment
elsepatch SearchAll_20030201.patch manage 2.7 K 07 Feb 2003 - 12:20 SamHasler Search Topic AND Text
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r9 < r8 < r7 < r6 < r5 | 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