Changeset 27781


Ignore:
Timestamp:
07/09/13 11:39:05 (8 years ago)
Author:
jmt12
Message:

Workaround for initial assignment of index shortnames (two places) - needs review

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm

    r25889 r27781  
    8080
    8181    # the text directory
    82     my $text_dir = &util::filename_cat($self->{'build_dir'}, "text");
    83     my $build_dir = &util::filename_cat($self->{'build_dir'},"");
    84     &util::mk_all_dir ($text_dir);
     82    my $text_dir = &FileUtils::filenameConcatenate($self->{'build_dir'}, "text");
     83    my $build_dir = &FileUtils::filenameConcatenate($self->{'build_dir'},"");
     84    &FileUtils::makeAllDirectories($text_dir);
    8585
    8686    my $osextra = "";
     
    205205}
    206206
     207# We need to push the list of indexfield to shortname mappings through to the
     208# build_cfg as, unlike in MGPP, we need these mappings in advance to configure
     209# Lucene/Solr. Unfortunately the original function found in mgbuilder.pm makes
     210# a mess of this - it only output fields that have been processed (none have)
     211# and it has a hardcoded renaming for 'text' so it becomes 'TX' according to
     212# the schema but 'TE' according to XML sent to lucene_passes.pl/solr_passes.pl
     213# This version is dumber - just copy them all across verbatum - but works. We
     214# do still need to support the special case of 'allfields'
     215sub make_final_field_list
     216{
     217  my $self = shift (@_);
     218  $self->{'build_cfg'} = {};
     219  my @indexfieldmap = ();
     220  my @indexfields = ();
     221
     222  # @todo support: $self->{'buildproc'}->{'extraindexfields'}
     223  foreach my $fields (@{$self->{'collect_cfg'}->{'indexes'}})
     224  {
     225    # remove subcoll stuff
     226    $fields =~ s/:.*$//;
     227    foreach my $field (split(';', $fields))
     228    {
     229      my $shortname = 'ERROR';
     230      if ($field eq 'allfields')
     231      {
     232        $shortname = 'ZZ';
     233      }
     234      elsif (defined $self->{'buildproc'}->{'indexfieldmap'}->{$field})
     235      {
     236        $shortname = $self->{'buildproc'}->{'indexfieldmap'}->{$field};
     237      }
     238      else
     239      {
     240        print STDERR 'Error! Couldn\'t find indexfieldmap for field: ' . $field . "\n";
     241      }
     242      push (@indexfieldmap, $field . '->' . $shortname);
     243      push (@indexfields, $field);
     244    }
     245  }
     246
     247  if (scalar @indexfieldmap)
     248  {
     249    $self->{'build_cfg'}->{'indexfieldmap'} = \@indexfieldmap;
     250  }
     251
     252  if (scalar @indexfields)
     253  {
     254    $self->{'build_cfg'}->{'indexfields'} = \@indexfields;
     255  }
     256}
     257
    207258# Generate solr schema.xml file based on indexmapfield and other associated
    208259# config files
     
    216267{
    217268    my $self = shift (@_);
    218    
     269
    219270    # Replace the following marker:
    220271    #
     
    226277    #
    227278    # for each <field> in 'indexfieldmap'
    228  
     279
    229280    my $schema_insert_xml = "";
    230281
     
    248299            $schema_insert_xml .= "type=\"text_en_splitting\" ";
    249300        }
    250         $schema_insert_xml .=  "indexed=\"true\" stored=\"false\" multiValued=\"true\" />\n";
     301        $schema_insert_xml .=  "indexed=\"true\" stored=\"false\" multiValued=\"true\" />\n";
     302                #$schema_insert_xml .=  "indexed=\"true\" stored=\"true\" multiValued=\"true\" />\n";
    251303    }
    252304
     
    257309       
    258310    my $solr_home = $ENV{'GEXT_SOLR'};
    259 ##    my $in_dirname = &util::filename_cat($solr_home,"etc","conf");
    260     my $in_dirname = &util::filename_cat($solr_home,"conf");
    261     my $schema_in_filename = &util::filename_cat($in_dirname,"schema.xml.in");
     311##    my $in_dirname = &FileUtils::filenameConcatenate($solr_home,"etc","conf");
     312    my $in_dirname = &FileUtils::filenameConcatenate($solr_home,"conf");
     313    my $schema_in_filename = &FileUtils::filenameConcatenate($in_dirname,"schema.xml.in");
    262314
    263315    my $collect_home = $ENV{'GSDLCOLLECTDIR'};
    264     my $out_dirname = &util::filename_cat($collect_home,"etc","conf");
    265     my $schema_out_filename = &util::filename_cat($out_dirname,"schema.xml");
     316    my $out_dirname = &FileUtils::filenameConcatenate($collect_home,"etc","conf");
     317    my $schema_out_filename = &FileUtils::filenameConcatenate($out_dirname,"schema.xml");
    266318   
    267319    # make sure output conf directory exists
    268     if (!-d $out_dirname) {
    269     &util::mk_dir($out_dirname);
     320    if (!FileUtils::directoryExists($out_dirname)) {
     321    &FileUtils::makeDirectory($out_dirname);
    270322    }
    271323
     
    279331 
    280332    foreach my $file ( @in_file_list ) {
    281     my $in_filename = &util::filename_cat($in_dirname,$file.".in");
    282     my $out_filename = &util::filename_cat($out_dirname,$file);
     333    my $in_filename = &FileUtils::filenameConcatenate($in_dirname,$file.".in");
     334    my $out_filename = &FileUtils::filenameConcatenate($out_dirname,$file);
    283335    filter_in_out_file($in_filename,$out_filename,[]);
    284336    }
     
    312364    my $allfields_index = 0;        # do we have an allfields index?
    313365
    314     # Using a hashmap here would duplications, but while more space
     366    # Using a hashmap here would avoid duplications, but while more space
    315367    # efficient, it's not entirely clear it would be more computationally
    316368    # efficient
     
    361413    my $buildproc = $self->{'buildproc'};
    362414   
    363     foreach my $field (@all_fields) {
    364         if (!defined $buildproc->{'indexfieldmap'}->{$field}) {
    365         my $shortname = $buildproc->create_shortname($field);
    366         $buildproc->{'indexfieldmap'}->{$field} = $shortname;
    367         $buildproc->{'indexfieldmap'}->{$shortname} = 1;
    368         }
    369     }
     415      foreach my $field (@all_fields)
     416      {
     417        if (!defined $buildproc->{'indexfieldmap'}->{$field})
     418        {
     419          my $shortname = '';
     420          if (defined $buildproc->{'fieldnamemap'}->{$field})
     421          {
     422            $shortname = $buildproc->{'fieldnamemap'}->{$field};
     423          }
     424          else
     425          {
     426            $shortname = $buildproc->create_shortname($field);
     427          }
     428          $buildproc->{'indexfieldmap'}->{$field} = $shortname;
     429          $buildproc->{'indexfieldmap'}->{$shortname} = 1;
     430        }
     431      }
    370432    }
    371433
     
    403465        $core = "building-".$core;
    404466
    405         my $full_index_dir = &util::filename_cat($build_dir,$index_dir);
    406         &util::rm_r($full_index_dir);
    407         &util::mk_dir($full_index_dir);
     467        my $full_index_dir = &FileUtils::filenameConcatenate($build_dir,$index_dir);
     468        &FileUtils::removeFilesRecursive($full_index_dir);
     469        &FileUtils::makeDirectory($full_index_dir);
    408470
    409471        # Solr then wants an "index" folder within this general index area!
    410 #       my $full_index_index_dir = &util::filename_cat($full_index_dir,"index");
    411 #       &util::mk_dir($full_index_index_dir);
     472#       my $full_index_index_dir = &FileUtils::filenameConcatenate($full_index_dir,"index");
     473#       &FileUtils::makeDirectory($full_index_index_dir);
    412474
    413475
     
    450512    # get the full index directory path and make sure it exists
    451513    my $indexdir = $self->{'index_mapping'}->{$index};
    452     &util::mk_all_dir (&util::filename_cat($build_dir, $indexdir));
     514    &FileUtils::makeAllDirectories(&FileUtils::filenameConcatenate($build_dir, $indexdir));
    453515
    454516    # Find the perl script to call to run solr
Note: See TracChangeset for help on using the changeset viewer.