Changeset 27781
- Timestamp:
- 2013-07-09T11:39:05+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm
r25889 r27781 80 80 81 81 # 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); 85 85 86 86 my $osextra = ""; … … 205 205 } 206 206 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' 215 sub 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 207 258 # Generate solr schema.xml file based on indexmapfield and other associated 208 259 # config files … … 216 267 { 217 268 my $self = shift (@_); 218 269 219 270 # Replace the following marker: 220 271 # … … 226 277 # 227 278 # for each <field> in 'indexfieldmap' 228 279 229 280 my $schema_insert_xml = ""; 230 281 … … 248 299 $schema_insert_xml .= "type=\"text_en_splitting\" "; 249 300 } 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"; 251 303 } 252 304 … … 257 309 258 310 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"); 262 314 263 315 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"); 266 318 267 319 # 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); 270 322 } 271 323 … … 279 331 280 332 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); 283 335 filter_in_out_file($in_filename,$out_filename,[]); 284 336 } … … 312 364 my $allfields_index = 0; # do we have an allfields index? 313 365 314 # Using a hashmap here would duplications, but while more space366 # Using a hashmap here would avoid duplications, but while more space 315 367 # efficient, it's not entirely clear it would be more computationally 316 368 # efficient … … 361 413 my $buildproc = $self->{'buildproc'}; 362 414 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 } 370 432 } 371 433 … … 403 465 $core = "building-".$core; 404 466 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); 408 470 409 471 # 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); 412 474 413 475 … … 450 512 # get the full index directory path and make sure it exists 451 513 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)); 453 515 454 516 # Find the perl script to call to run solr
Note:
See TracChangeset
for help on using the changeset viewer.