Changeset 27803 for main/trunk


Ignore:
Timestamp:
2013-07-11T11:44:20+12:00 (11 years ago)
Author:
kjdon
Message:

code for sort and facet lists

Location:
main/trunk/greenstone2/perllib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/buildConfigxml.pm

    r26094 r27803  
    371371    $settings->{'default_db_level'} = $default_db_level;
    372372
    373    
     373    # sort field list
     374    ######
     375
     376    my $sortmap = {};  # maps index name to shortname
     377    my $sortlist = []; # keeps the order for indexes
     378
     379    if (defined ($buildcfg->{"indexsortfieldmap"})) {
     380    my $sortmap_t = $buildcfg->{"indexsortfieldmap"};
     381    foreach my $s (@$sortmap_t) {
     382        my ($k, $v) = $s =~ /^(.*)\-\>(.*)$/;
     383        $sortmap->{$v} = $k;
     384    }
     385    }
     386    if (defined ($buildcfg->{"indexsortfields"})) {
     387    $sortlist = $buildcfg->{"indexsortfields"};
     388    }
     389
     390    $settings->{'sortlist'} = $sortlist;
     391    $settings->{'sortmap'} = $sortmap;
     392
     393    ### TODO make these use facets not the sort list
     394    $settings->{'facetlist'} = $sortlist;
     395    $settings->{'facetmap'} = $sortmap;
     396
     397
    374398    return $settings;
    375399}
     
    458482    if ($buildtype eq "lucene" || $buildtype eq "mgpp" || $buildtype eq "solr") {
    459483        &write_line('COLCFG', ["<defaultDBLevel shortname=\"", $default_db_level, "\" />"]);
     484    }
     485
     486    # do sort list
     487    if ($buildtype eq "lucene" || $buildtype eq "solr") {
     488    my $sortlist = $settings->{'sortlist'};
     489    my $sortmap = $settings->{'sortmap'};
     490    &write_line('COLCFG', ["<sortList>"]);
     491    foreach my $sf (@$sortlist) {
     492        my $sortf = $sortmap->{$sf};
     493        &write_line('COLCFG', ["<sort name=\"", $sortf, "\" shortname=\"", $sf, "\" />"]);
     494    }
     495    &write_line('COLCFG', ["</sortList>"]);
     496    }
     497
     498    # do facet list
     499    if ($buildtype eq "solr") {
     500    &write_line('COLCFG', ["<facetList>"]);
     501    my $facetlist = $settings->{'facetlist'};
     502    my $facetmap = $settings->{'facetmap'};
     503    foreach my $ff (@$facetlist) {
     504        my $facetf = $facetmap->{$ff};
     505        &write_line('COLCFG', ["<facet name=\"", $ff, "\" shortname=\"", $facetf, "\" />"]);
     506    }
     507    &write_line('COLCFG', ["</facetList>"]);
    460508    }
    461509    # do searchTypeList
  • main/trunk/greenstone2/perllib/collConfigxml.pm

    r27192 r27803  
    5151           "defaultIndexLanguage" => "defaultlanguage",
    5252           "index" => "indexes",
     53           "sort" => "sortfields",
     54           "facet" => "facetfields",
    5355           "plugin" => "plugin",
    5456           "plugout" => "plugout",
     
    8183# ("plugin", "option")
    8284my $currentIndex = 0;
    83 my $arrayexp = q/^(index|level|indexOption|indexSubcollection|indexLanguage|orthogonalBuildTypes)$/;
     85my $arrayexp = q/^(index|sort|facet|level|indexOption|indexSubcollection|indexLanguage|orthogonalBuildTypes)$/;
    8486my $arrayarrayexp = q/^(plugin|classifier)$/; #|buildOption)$/;
    8587my $hashexp = q/^(subcollection)$/; # add other element names that should be represented by hash expressions here
     
    196198    #}
    197199 
    198     #@ Handle index|level|indexOption|indexSubcollection|indexLanguage
     200    #@ Handle index|sort|facet|level|indexOption|indexSubcollection|indexLanguage
    199201    elsif ($element =~ /$arrayexp/) {
    200202      my $key = $nameMap->{$element};   
Note: See TracChangeset for help on using the changeset viewer.