Changeset 4962


Ignore:
Timestamp:
09/17/09 15:27:21 (3 years ago)
Author:
AndrewJones
Message:

Item1363: add ability to skip topics

Location:
trunk/SearchEngineKinoSearchAddOn
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SearchEngineKinoSearchAddOn/lib/Foswiki/Contrib/SearchEngineKinoSearchAddOn/Config.spec

    r4913 r4962  
    1414# For example: Web.SomeTopic.AnAttachment.txt, Web.OtherTopic.OtherAttachment.pdf 
    1515$Foswiki::cfg{SearchEngineKinoSearchAddOn}{SkipAttachments} = ''; 
     16 
     17# **STRING** 
     18# List of topics to skip. 
     19# Topics can be in the form of Web.MyTopic, or if you want a topic to be excluded from all webs just enter MyTopic. 
     20# For example: Main.WikiUsers, WebStatistics 
     21$Foswiki::cfg{SearchEngineKinoSearchAddOn}{SkipTopics} = ''; 
    1622 
    1723# **STRING** 
  • trunk/SearchEngineKinoSearchAddOn/lib/Foswiki/Contrib/SearchEngineKinoSearchAddOn/Index.pm

    r4914 r4962  
    4747 
    4848    # FIXME: Make it more clear. 
    49     $self->{Debug} = $debug; 
     49    $self->{Debug} = $debug || $Foswiki::cfg{SearchEngineKinoSearchAddOn}{Debug} || 0; 
    5050 
    5151    $self->log( "Indexing started", 1 ); 
     
    5959 
    6060    my @webs = $self->websToIndex(); 
     61     
     62    # get the list of topics not to be indexed 
     63    my %skipTopics = $self->skipTopics; 
    6164 
    6265    foreach my $web (@webs) { 
     
    6669 
    6770        foreach my $topic ( Foswiki::Func::getTopicList($web) ) { 
     71            next if ( ( $skipTopics{"$web.$topic"} ) || ( $skipTopics{$topic} ) ); 
     72             
    6873            $self->log("Indexing topic | $web.$topic"); 
    6974            $self->indexTopic( $invindexer, $web, $topic, %fldNames ); 
     
    206211    my @topicsToUpdate; 
    207212 
     213    # get the list of topics not to be indexed 
     214    my %skipTopics = $self->skipTopics; 
     215     
    208216    # do not process the same topic twice 
    209217    my %exclude; 
     
    216224        my ( $topicName, $userName, $changeTime, $revision ) = 
    217225          split( /\t/, $change ); 
     226           
     227        next if ( ( $skipTopics{"$web.$topicName"} ) || ( $skipTopics{$topicName} ) ); 
    218228 
    219229        if ( ( !%exclude ) || ( !$exclude{$topicName} ) ) { 
  • trunk/SearchEngineKinoSearchAddOn/lib/Foswiki/Contrib/SearchEngineKinoSearchAddOn/KinoSearch.pm

    r4835 r4962  
    6262        $self->{Log}->print( "| $logtime | $logString\n"); 
    6363 
    64         print STDERR "$logString\n"; 
     64        #print STDERR "$logString\n"; 
    6565    } 
     66    $self->{Debug} && Foswiki::Func::writeDebug( $logString ); 
    6667} 
    6768 
     
    125126# QS 
    126127sub skipAttachments { 
    127     # SMELL: whats the best way to define skipped attachments? 
    128128    my $to_skip = $Foswiki::cfg{SearchEngineKinoSearchAddOn}{SkipAttachments} || ''; 
    129129    my %skipattachments; 
     
    136136} 
    137137 
     138# List of topics to be skipped. 
     139sub skipTopics { 
     140    my $to_skip = $Foswiki::cfg{SearchEngineKinoSearchAddOn}{SkipTopics} || ''; 
     141    my %skiptopics; 
     142 
     143    foreach my $t ( split( /\,\s+/, $to_skip ) ) { 
     144        $skiptopics{$t} = 1; 
     145    } 
     146     
     147    return %skiptopics; 
     148} 
     149 
    138150# List of file extensions to be indexed 
    139151# QS 
    140152sub indexExtensions { 
    141     my $extensions = $Foswiki::cfg{SearchEngineKinoSearchAddOn}{IndexExtensions} || ".pdf, .doc, .xml, .html, .txt, .xls, .ppt"; 
     153    my $extensions = $Foswiki::cfg{SearchEngineKinoSearchAddOn}{IndexExtensions} || ".txt, .html, .xml, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .pdf"; 
    142154    my %indexextensions; 
    143155 
  • trunk/SearchEngineKinoSearchAddOn/test/unit/SearchEngineKinoSearchAddOn/KinoSearchTests.pm

    r4935 r4962  
    118118 
    119119    my @config_atts  = ("att1", "att2"); 
    120     my $a_att; 
    121120 
    122121    $Foswiki::cfg{SearchEngineKinoSearchAddOn}{SkipAttachments} = ""; 
     
    127126    $Foswiki::cfg{SearchEngineKinoSearchAddOn}{SkipAttachments} = "att1, att2"; 
    128127    %atts = $ks->skipAttachments(); 
    129     foreach $a_att (@config_atts) { 
     128    foreach my $a_att (@config_atts) { 
    130129        $this->assert($atts{$a_att}, "Attachment $a_att not skipped in config.") 
     130        } 
     131} 
     132 
     133sub test_skipTopics { 
     134    my $this = shift; 
     135    my $ks = new Foswiki::Contrib::SearchEngineKinoSearchAddOn::KinoSearch("index"); 
     136 
     137    my @config_atts  = ("Web.MyTopic", "MyOtherTopic"); 
     138 
     139    $Foswiki::cfg{SearchEngineKinoSearchAddOn}{SkipTopics} = ""; 
     140    my %atts = $ks->skipTopics(); 
     141    my $num = %atts; 
     142    $this->assert($num == 0, "List of skipped attachments not empty. : $num"); 
     143 
     144    $Foswiki::cfg{SearchEngineKinoSearchAddOn}{SkipTopics} = "Web.MyTopic, MyOtherTopic"; 
     145    %atts = $ks->skipTopics(); 
     146    foreach my $t (@config_atts) { 
     147        $this->assert($atts{$t}, "Topic $t not skipped in config.") 
    131148        } 
    132149} 
Note: See TracChangeset for help on using the changeset viewer.