Changeset 4768


Ignore:
Timestamp:
2003-06-23T14:49:14+12:00 (21 years ago)
Author:
kjdon
Message:

changed the index specification for mgpp colls. now we only build one index, and the contents are separated by spaces, eg
indexes text Title Subject metadata allfields
these are all built into one index. the field list is used inplace of index list in the query form. the order of teh indexes line specifies the order they should appear in the field list.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/mgppbuilder.pm

    r3805 r4768  
    6363
    6464# change this so a user can add their own ones in via a file or cfg
     65#add AND, OR, NOT NEAR to this list - these cannot be used as field names
    6566%static_indexfield_map = ('Title'=>'TI',
    6667              'TI'=>1,
     
    6970              'Creator'=>'CR',
    7071              'CR'=>1,
    71               'Organization'=>'OR',
    72               'OR'=>1,
     72              'Organization'=>'ORG',
     73              'ORG'=>1,
    7374              'Source'=>'SO',
    7475              'SO'=>1,
     
    8182              'People'=>'PE',
    8283              'PE'=>1,
     84              'AllFields'=>'ZZ',
     85              'ZZ'=>1,
    8386              'TextOnly'=>'TX',
    84               'TX'=>1);
     87              'TX'=>1,
     88              'AND'=>1,
     89              'OR'=>1,
     90              'NOT'=>1,
     91              'NEAR'=>1);
    8592
    8693sub new {
     
    115122    $self->{'collect_cfg'} = &colcfg::read_collect_cfg ($colcfgname);
    116123
     124    # sort out the indexes
     125    #indexes are specified with spaces, but we put them into one index
     126    my $indexes = $self->{'collect_cfg'}->{'indexes'};
     127    $self->{'collect_cfg'}->{'indexes'} = [];
     128    push (@{$self->{'collect_cfg'}->{'indexes'}}, join(',', @$indexes));
     129     
     130   
    117131    # sort out subcollection indexes
    118132    if (defined $self->{'collect_cfg'}->{'indexsubcollections'}) {
     
    402416
    403417    # the directory name starts with a processed version of index fields
    404     my ($pindex) = $self->process_field($fields);
    405     # next comes a processed version of the index
    406     $pindex = lc ($pindex);
    407 
     418    #my ($pindex) = $self->process_field($fields);
     419    #$pindex = lc ($pindex);
     420    # now we only ever have one index, and its called 'idx'
     421    $pindex = 'idx';
     422   
    408423    # next comes a processed version of the subcollection if there is one.
    409424    my $psub = $self->process_field ($subcollection);
     
    900915    # store the indexfieldmap information
    901916    my @indexfieldmap = ();
    902     #add all fields bit - sort based on keys. text only is put at front
    903     if (defined $self->{'buildproc'}->{'indexfields'}->{'TextOnly'}) {
    904     push (@indexfieldmap, "TextOnly\-\>TX");
    905     }
    906     foreach $field (sort keys %{$self->{'buildproc'}->{'indexfields'}}) {
    907     next if $field eq "TextOnly";
    908     push (@indexfieldmap, "$field\-\>$self->{'buildproc'}->{'indexfieldmap'}->{$field}");
     917    my @indexfields = ();
     918    my $specifiedfields = {};
     919    my @specifiedfieldorder = ();
     920    # go through the index definition and add each thing to a map, so we can easily check if it is already specified - when doing the metadata, we print out all the individual fields, but some may already be specified in the index definition, so we dont want to add those again.
     921    foreach $field (@{$self->{'collect_cfg'}->{'indexes'}}) {
     922    my @fs = split(',', $field);
     923    foreach $f(@fs) {
     924        $specifiedfields->{$f}=1;
     925        push (@specifiedfieldorder, "$f");
     926    }
     927    }
     928   
     929    #add all fields bit
     930    foreach $field (@specifiedfieldorder) {
     931    if ($field eq "metadata") {
     932        foreach $newfield (keys %{$self->{'buildproc'}->{'indexfields'}}) {
     933        if (!defined $specifiedfields->{$newfield}) {
     934            push (@indexfieldmap, "$newfield\-\>$self->{'buildproc'}->{'indexfieldmap'}->{$newfield}");
     935            push (@indexfields, "$newfield");
     936        }
     937        }
     938
     939    } elsif ($field eq 'text') {
     940        push (@indexfieldmap, "TextOnly\-\>TX");
     941        push (@indexfields, "TextOnly");
     942    } elsif ($field eq 'allfields') {
     943        push (@indexfieldmap, "AllFields\-\>ZZ");
     944        push (@indexfields, "AllFields");
     945    } else {
     946        push (@indexfieldmap, "$field\-\>$self->{'buildproc'}->{'indexfieldmap'}->{$field}");
     947        push (@indexfields, "$field");
     948       
     949    }
     950    #if (defined $self->{'buildproc'}->{'indexfields'}->{'TextOnly'}) {
     951    #push (@indexfieldmap, "TextOnly\-\>TX");
     952    #}
     953    #foreach $field (sort keys %{$self->{'buildproc'}->{'indexfields'}}) {
     954    #next if $field eq "TextOnly";
     955    #push (@indexfieldmap, "$field\-\>$self->{'buildproc'}->{'indexfieldmap'}->{$field}");
    909956    }
    910957
    911958    $build_cfg->{'indexfieldmap'} = \@indexfieldmap;
     959    $build_cfg->{'indexfields'} = \@indexfields;
    912960
    913961    #store the indexed field information
    914     foreach $field (sort keys %{$self->{'buildproc'}->{'indexfields'}}) {
     962    #foreach $field (sort keys %{$self->{'buildproc'}->{'indexfields'}}) {
    915963   
    916     push (@{$build_cfg->{'indexfields'}}, $field);
    917     }
     964    #push (@{$build_cfg->{'indexfields'}}, $field);
     965    #}
    918966    # write out the build information
    919967    &cfgread::write_cfg_file("$self->{'build_dir'}/build.cfg", $build_cfg,
Note: See TracChangeset for help on using the changeset viewer.