Ignore:
Timestamp:
2007-02-14T16:30:34+13:00 (17 years ago)
Author:
kjdon
Message:

changed the format of index and field info in buildConfig and collectionConfig. No fields any more, just use indexes. index has a shortname and a name - name comes from collect.cfg, shortname from build.cfg, eg text and TX, or section:text and ste. mg/mgpp/lucene colls config files are moresimilar now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/bin/script/convert_coll_from_gs2.pl

    r13843 r13912  
    175175   
    176176    #indexes
     177    # maps index name to shortname
    177178    my $indexmap = {};
     179    # keeps the order for indexes
     180    my @indexlist = ();
    178181    my $firstindex = "";
    179182    my $first = 1;
    180     if (defined $buildcfg->{'indexmap'}) {
    181     my $indexmap_t = $buildcfg->{'indexmap'};
     183    my $maptype = "indexfieldmap";
     184    if ($buildtype eq "mg") {
     185    $maptype = "indexmap";
     186    }
     187    if (defined $buildcfg->{$maptype}) {
     188    my $indexmap_t = $buildcfg->{$maptype};
    182189    foreach my $i (@$indexmap_t) {
    183190        my ($k, $v) = $i =~ /^(.*)\-\>(.*)$/;
    184191        $indexmap->{$k} = $v;
     192        push @indexlist, $k;
    185193        if ($first) {
    186194        $firstindex = $v;
     
    189197    }
    190198    } else {
    191     print STDERR "indexmap not defined";
    192     }
     199    print STDERR "$maptype not defined";
     200    }
     201    # we use the shortname for default index
    193202    my $defaultindex;
    194     if ($buildtype eq "mg") {
    195     if (defined $collectcfg->{'defaultindex'}) {
    196         $defaultindex = $collectcfg->{'defaultindex'};
    197         $defaultindex = $indexmap->{$defaultindex};
    198     } else {
    199         # use the first one
    200         $defaultindex = $firstindex;
    201     }
    202     }
    203     elsif ($buildtype eq "mgpp") {
    204     $defaultindex = "idx";
    205     }
    206     elsif ($buildtype eq "lucene") {
    207     # lucene not implemented yet
    208     $defaultindex = "idx";
     203    if (defined $collectcfg->{'defaultindex'}) {
     204    $defaultindex = $collectcfg->{'defaultindex'};
     205    $defaultindex = $indexmap->{$defaultindex};
     206    } else {
     207    # use the first one
     208    $defaultindex = $firstindex;
    209209    }
    210210   
     
    215215    $collwriter->startTag('search');
    216216    foreach my $i (keys %$indexmap) {
    217     my $shortname = $indexmap->{$i};
    218     $collwriter->startTag('index', 'name'=>$shortname);
     217    $collwriter->startTag('index', 'name'=>$i);
    219218    #find the coll meta stuff
    220219    my $indexdisplay = ".$i";
     
    224223    }
    225224    $collwriter->endTag('index');
    226    
    227225    }
    228226
     
    246244    my @levels = ();
    247245    my $defaultlevel;
    248     my $service_name = "";
     246    my $service_type = "MG";
     247    if ($buildtype eq 'mgpp') {
     248    $service_type = "MGPP";
     249    } elsif ($buildtype eq "lucene") {
     250    $service_type = "Lucene";
     251    }
     252
    249253    #do the retrieve service
    250254    # assume mgpp or mg
     
    271275        }
    272276    }
    273     if ($buildtype eq 'mgpp') {
    274         $service_name = "MGPP";
    275     } else {
    276         $service_name = "Lucene";
    277     }
    278     $buildwriter->startTag('serviceRack', 'name'=>"GS2".$service_name."Retrieve");
     277    $buildwriter->startTag('serviceRack', 'name'=>"GS2".$service_type."Retrieve");
    279278    $buildwriter->emptyTag('defaultLevel', 'name'=>$defaultlevel);
    280279
     
    282281    } elsif ($buildtype eq "mg") {
    283282    $buildwriter->startTag('serviceRack', 'name'=>'GS2MGRetrieve');
    284     $buildwriter->emptyTag('defaultIndex', 'name'=>$defaultindex);
     283    $buildwriter->emptyTag('defaultIndex', 'shortname'=>$defaultindex);
    285284   
    286285    }
     
    399398   
    400399    # do the search service
     400    $buildwriter->startTag('serviceRack', 'name'=>'GS2'.$service_type.'Search');
     401    $buildwriter->emptyTag('defaultIndex', 'shortname'=>$defaultindex);
     402    $buildwriter->startTag('indexList');
     403    #for each index
     404    foreach my $i (@indexlist) {
     405    my $index = $indexmap->{$i};
     406    $buildwriter->emptyTag('index', 'name'=>$i, 'shortname'=>$index);
     407    }   
     408    $buildwriter->endTag('indexList');
     409    if (defined $indexstem) {
     410    $buildwriter->emptyTag('indexStem', 'name'=>$indexstem);
     411    }
     412   
     413    # index options
     414    if ($buildtype eq 'mg' || $buildtype eq 'mgpp') {
     415    $buildwriter->startTag('indexOptionList');
     416    my $stemindexes = 3; # default is stem and casefold
     417    if (defined $buildcfg->{'stemindexes'} && $buildcfg->{'stemindexes'} =~ /^\d+$/ ) {
     418        $stemindexes = $buildcfg->{'stemindexes'};
     419    }
     420    $buildwriter->emptyTag('indexOption', 'name'=>'stemIndexes', 'value'=>$stemindexes);
     421   
     422    my $maxnumeric = 4; # default
     423    if (defined $buildcfg->{'maxnumeric'} && $buildcfg->{'maxnumeric'} =~ /^\d+$/) {
     424        $maxnumeric = $buildcfg->{'maxnumeric'};
     425    }
     426    $buildwriter->emptyTag('indexOption', 'name'=>'maxnumeric', 'value'=>$maxnumeric);
     427   
     428    $buildwriter->endTag('indexOptionList');
     429    }
     430
    401431    if ($buildtype eq 'mgpp' || $buildtype eq 'lucene') {
    402432       
    403     $buildwriter->startTag('serviceRack', 'name'=>'GS2'.$service_name.'Search');
     433    # level info
    404434    $buildwriter->emptyTag('defaultLevel', 'name'=>$defaultlevel);
    405435    $buildwriter->startTag('levelList');
     
    409439    $buildwriter->endTag('levelList');
    410440   
    411     #fieldlist
    412     my $fieldmap = {};
    413     my $fieldlist = ();
    414     if (defined $buildcfg->{'indexfields'}) {
    415         push @$fieldlist, @{$buildcfg->{'indexfields'}};
    416         if (defined $buildcfg->{'indexfieldmap'}) {
    417         my $fieldmap_t = $buildcfg->{'indexfieldmap'};
    418         foreach my $f (@$fieldmap_t) {
    419             my ($k, $v) = $f =~ /^(.*)\-\>(.*)$/;
    420             $fieldmap->{$k} = $v;
    421         }
    422         }
    423         $buildwriter->startTag('fieldList');
    424         foreach my $f (@$fieldlist) {
    425         my $field = $fieldmap->{$f};
    426         $buildwriter->emptyTag('field', 'shortname'=>$field, 'name'=>$f);
    427         }   
    428         $buildwriter->endTag('fieldList');
    429     } else {
    430         print STDERR "indexfieldmap not defined";
    431     }
    432 
    433441    # do the search types if there
    434442    if (defined $collectcfg->{'searchtype'}) {
     
    450458        $buildwriter->endTag('searchTypeList');
    451459    }
    452     } elsif ($buildtype eq 'mg') {
    453     $buildwriter->startTag('serviceRack', 'name'=>'GS2MGSearch');
    454     }
    455    
    456     if (defined $indexstem) {
    457     $buildwriter->emptyTag('indexStem', 'name'=>$indexstem);
    458460    }
    459 
    460     # index options
    461     if ($buildtype eq 'mg' || $buildtype eq 'mgpp') {
    462     $buildwriter->startTag('indexOptionList');
    463     my $stemindexes = 3; # default is stem and casefold
    464     if (defined $buildcfg->{'stemindexes'} && $buildcfg->{'stemindexes'} =~ /^\d+$/ ) {
    465         $stemindexes = $buildcfg->{'stemindexes'};
    466     }
    467     $buildwriter->emptyTag('indexOption', 'name'=>'stemIndexes', 'value'=>$stemindexes);
    468    
    469     my $maxnumeric = 4; # default
    470     if (defined $buildcfg->{'maxnumeric'} && $buildcfg->{'maxnumeric'} =~ /^\d+$/) {
    471         $maxnumeric = $buildcfg->{'maxnumeric'};
    472     }
    473     $buildwriter->emptyTag('indexOption', 'name'=>'maxnumeric', 'value'=>$maxnumeric);
    474    
    475     $buildwriter->endTag('indexOptionList');
    476     }
    477     $buildwriter->emptyTag('defaultIndex', 'name'=>$defaultindex);
    478     $buildwriter->startTag('indexList');
    479     #for each index
    480     foreach my $i (keys %$indexmap) {
    481     my $index = $indexmap->{$i};
    482     $buildwriter->emptyTag('index', 'name'=>$index);
    483     }   
    484     $buildwriter->endTag('indexList');
     461   
     462
    485463   
    486464    $buildwriter->endTag('serviceRack');
Note: See TracChangeset for help on using the changeset viewer.