source: gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm@ 29176

Last change on this file since 29176 was 29176, checked in by ak19, 10 years ago

For Solr: 1. collConfig.pm now reads any option sub-elements for index elements defined in collectionConfig.xml. 2. The solrfieldtype option sub-element to an index element can now be set by hand in collectionConfig.xml and its value will be used in the solr collection/etc/conf/schema.xml file for that index in that collection, instead of the old default of text_en_splitting for all fields.

File size: 21.9 KB
Line 
1###########################################################################
2#
3# solrbuilder.pm -- perl wrapper for building index with Solr
4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 1999 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
26
27package solrbuilder;
28
29use strict;
30no strict 'refs';
31
32use lucenebuilder;
33use solrserver;
34use Config; # for getting the perlpath in the recommended way
35
36sub BEGIN {
37 @solrbuilder::ISA = ('lucenebuilder');
38}
39
40
41sub new {
42 my $class = shift(@_);
43 my $self = new lucenebuilder (@_);
44 $self = bless $self, $class;
45
46 $self->{'buildtype'} = "solr";
47
48 my $solr_passes_script = "solr_passes.pl";
49
50 $self->{'solr_passes'} = "$solr_passes_script";
51 # Tack perl on the beginning to ensure execution
52 $self->{'solr_passes_exe'} = "\"$Config{perlpath}\" -S \"$solr_passes_script\"";
53 return $self;
54}
55
56
57sub default_buildproc {
58 my $self = shift (@_);
59
60 return "solrbuildproc";
61}
62
63# This writes a nice version of the text docs
64#
65# Essentially the same as the lucenebuilder.pm version, only using solr_passes
66# => refactor and make better use of inheritence
67#
68sub compress_text
69{
70 my $self = shift (@_);
71 # do nothing if we don't want compressed text
72 return if $self->{'no_text'};
73
74 my ($textindex) = @_;
75
76 # workaround to avoid hard-coding "solr" check into buildcol.pl
77 $textindex =~ s/^section://;
78
79 my $outhandle = $self->{'outhandle'};
80
81 # the text directory
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
86 my $osextra = "";
87 if ($ENV{'GSDLOS'} =~ /^windows$/i)
88 {
89 $text_dir =~ s@/@\\@g;
90 }
91 else
92 {
93 if ($outhandle ne "STDERR")
94 {
95 # so solr_passes doesn't print to stderr if we redirect output
96 $osextra .= " 2>/dev/null";
97 }
98 }
99
100 # Find the perl script to call to run solr
101 my $solr_passes = $self->{'solr_passes'};
102 my $solr_passes_exe = $self->{'solr_passes_exe'};
103
104 my $solr_passes_sections = "Doc";
105
106 my ($handle);
107
108 if ($self->{'debug'})
109 {
110 $handle = *STDOUT;
111 }
112 else
113 {
114 my $site = $self->{'site'};
115 my $collect = $self->{'collection'};
116 my $core_prefix = (defined $site) ? "$site-$collect" : $collect;
117 my $core = $core_prefix; # unused in this call to solr_passes
118
119 $core = "building-".$core unless $self->{'incremental'}; # core points to building only for force_removeold
120
121 print STDERR "Executable: $solr_passes_exe\n";
122 print STDERR "Sections: $solr_passes_sections\n";
123 print STDERR "Build Dir: $build_dir\n";
124 print STDERR "Cmd: $solr_passes_exe $core text \"$build_dir\" \"dummy\" $osextra\n";
125 if (!open($handle, "| $solr_passes_exe $core text \"$build_dir\" \"dummy\" $osextra"))
126 {
127 print STDERR "<FatalError name='NoRunSolrPasses'/>\n</Stage>\n" if $self->{'gli'};
128 die "solrbuilder::build_index - couldn't run $solr_passes_exe\n$!\n";
129 }
130 }
131
132 # stored text is always Doc and Sec levels
133 my $levels = { 'document' => 1, 'section' => 1 };
134 # always do database at section level
135 my $db_level = "section";
136
137 # set up the document processr
138 $self->{'buildproc'}->set_output_handle ($handle);
139 $self->{'buildproc'}->set_mode ('text');
140 $self->{'buildproc'}->set_index ($textindex);
141 $self->{'buildproc'}->set_indexing_text (0);
142 #$self->{'buildproc'}->set_indexfieldmap ($self->{'indexfieldmap'});
143 $self->{'buildproc'}->set_levels ($levels);
144 $self->{'buildproc'}->set_db_level ($db_level);
145 $self->{'buildproc'}->reset();
146
147 &plugin::begin($self->{'pluginfo'}, $self->{'source_dir'},
148 $self->{'buildproc'}, $self->{'maxdocs'});
149 &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
150 "", {}, {}, $self->{'buildproc'}, $self->{'maxdocs'}, 0, $self->{'gli'});
151 &plugin::end($self->{'pluginfo'});
152
153 close ($handle) unless $self->{'debug'};
154 $self->print_stats();
155
156 print STDERR "</Stage>\n" if $self->{'gli'};
157}
158
159#----
160
161
162
163sub filter_in_out_file
164{
165 my ($in_filename,$out_filename,$replace_rules) = @_;
166
167 if (open(SIN,"<$in_filename")) {
168
169 if (open(SOUT,">$out_filename")) {
170
171 my $line;
172 while (defined ($line=<SIN>)) {
173 chomp $line;
174
175 my $done_insert = 0;
176 foreach my $rule (@$replace_rules) {
177 my $line_re = $rule->{'regexp'};
178 my $insert = $rule->{'insert'};
179
180 if ($line =~ m/$line_re/) {
181 print SOUT $insert;
182 $done_insert = 1;
183 last;
184 }
185 }
186 if (!$done_insert) {
187 print SOUT "$line\n";;
188 }
189 }
190
191 close(SOUT);
192 }
193 else {
194 print STDERR "Error: Failed to open $out_filename\n";
195 print STDERR " $!\n";
196 }
197
198 close(SIN);
199 }
200 else {
201 print STDERR "Error: Failed to open $in_filename\n";
202 print STDERR " $!\n";
203 }
204
205}
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'
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
258# Generate solr schema.xml file based on indexmapfield and other associated
259# config files
260#
261# Unlike make_auxiliary_files(), this needs to be done up-front (rather
262# than at the end) so the data-types in schema.xml are correctly set up
263# prior to document content being pumped through solr_passes.pl
264
265
266sub premake_solr_auxiliary_files
267{
268 my $self = shift (@_);
269
270 # Replace the following marker:
271 #
272 # <!-- ##GREENSTONE-FIELDS## -->
273 #
274 # with lines of the form:
275 #
276 # <field name="<field>" type="string" ... />
277 #
278 # for each <field> in 'indexfieldmap'
279
280 my $schema_insert_xml = "";
281
282 foreach my $ifm (@{$self->{'build_cfg'}->{'indexfieldmap'}}) {
283
284 my ($fullfieldname, $field) = ($ifm =~ m/^(.*)->(.*)$/);
285
286 $schema_insert_xml .= " "; # indent
287 $schema_insert_xml .= "<field name=\"$field\" ";
288
289 if($field eq "LA" || $field eq "LO")
290 {
291 $schema_insert_xml .= "type=\"location\" ";
292 }
293# elsif ($field ne "ZZ" && $field ne "TX")
294# {
295# $schema_insert_xml .= "type=\"string\" ";
296# }
297 else
298 {
299 #$schema_insert_xml .= "type=\"text_en_splitting\" ";
300
301 # original default solr field type for all fields is text_en_splitting
302 my $solrfieldtype = "text_en_splitting";
303 if(defined $self->{'collect_cfg'}->{'indexfieldoptions'}->{$fullfieldname}->{'solrfieldtype'}) {
304 $solrfieldtype = $self->{'collect_cfg'}->{'indexfieldoptions'}->{$fullfieldname}->{'solrfieldtype'};
305 #print STDERR "@@@@#### found TYPE: $solrfieldtype\n";
306 }
307 $schema_insert_xml .= "type=\"$solrfieldtype\" ";
308
309 }
310 # set termVectors=\"true\" when term vectors info is required,
311 # see TermsResponse termResponse = solrResponse.getTermsResponse();
312 #$schema_insert_xml .= "indexed=\"true\" stored=\"false\" termVectors=\"true\" multiValued=\"true\" />\n";
313 $schema_insert_xml .= "indexed=\"true\" stored=\"false\" multiValued=\"true\" />\n";
314 #$schema_insert_xml .= "indexed=\"true\" stored=\"true\" multiValued=\"true\" />\n";
315 }
316
317 # just the one rule to date
318 my $insert_rules
319 = [ { 'regexp' => "^\\s*<!--\\s*##GREENSTONE-FIELDS##\\s*-->\\s*\$",
320 'insert' => $schema_insert_xml } ];
321
322 my $solr_home = $ENV{'GEXT_SOLR'};
323## my $in_dirname = &FileUtils::filenameConcatenate($solr_home,"etc","conf");
324 my $in_dirname = &FileUtils::filenameConcatenate($solr_home,"conf");
325 my $schema_in_filename = &FileUtils::filenameConcatenate($in_dirname,"schema.xml.in");
326
327 my $collect_home = $ENV{'GSDLCOLLECTDIR'};
328 my $out_dirname = &FileUtils::filenameConcatenate($collect_home,"etc","conf");
329 my $schema_out_filename = &FileUtils::filenameConcatenate($out_dirname,"schema.xml");
330
331 # make sure output conf directory exists
332 if (!&FileUtils::directoryExists($out_dirname)) {
333 &FileUtils::makeDirectory($out_dirname);
334 }
335
336 filter_in_out_file($schema_in_filename,$schema_out_filename,$insert_rules);
337
338 # now do the same for solrconfig.xml, stopwords, ...
339 # these are simpler, as they currently do not need any filtering
340
341 my @in_file_list = ( "solrconfig.xml", "stopwords.txt", "stopwords_en.txt",
342 "synonyms.txt", "protwords.txt", "currency.xml", "elevate.xml" );
343
344 foreach my $file ( @in_file_list ) {
345 my $in_filename = &FileUtils::filenameConcatenate($in_dirname,$file.".in");
346 my $out_filename = &FileUtils::filenameConcatenate($out_dirname,$file);
347
348 if(&FileUtils::fileExists($in_filename)) {
349 filter_in_out_file($in_filename,$out_filename,[]);
350 }
351 }
352
353 my @in_dir_list = ( "lang" );
354 foreach my $dir ( @in_dir_list ) {
355
356 my $full_subdir_name = &FileUtils::filenameConcatenate($in_dirname,$dir);
357
358 if(&FileUtils::directoryExists($full_subdir_name)) {
359 &FileUtils::copyFilesRecursiveNoSVN($full_subdir_name, $out_dirname);
360 }
361 }
362}
363
364
365sub pre_build_indexes
366{
367 my $self = shift (@_);
368 my ($indexname) = @_;
369 my $outhandle = $self->{'outhandle'};
370
371 # If the Solr/Jetty server is not already running, the following starts
372 # it up, and only returns when the server is "reading and listening"
373
374 my $solr_server = new solrserver($self->{'build_dir'});
375 $solr_server->start();
376 $self->{'solr_server'} = $solr_server;
377
378 my $indexes = [];
379 if (defined $indexname && $indexname =~ /\w/) {
380 push @$indexes, $indexname;
381 } else {
382 $indexes = $self->{'collect_cfg'}->{'indexes'};
383 }
384
385 # skip para-level check, as this is done in the main 'build_indexes'
386 # routine
387
388 my $all_metadata_specified = 0; # has the user added a 'metadata' index?
389 my $allfields_index = 0; # do we have an allfields index?
390
391 # Using a hashmap here would avoid duplications, but while more space
392 # efficient, it's not entirely clear it would be more computationally
393 # efficient
394 my @all_fields = ();
395
396 foreach my $index (@$indexes) {
397 if ($self->want_built($index)) {
398
399 # get the parameters for the output
400 # split on : just in case there is subcoll and lang stuff
401 my ($fields) = split (/:/, $index);
402
403 foreach my $field (split (/;/, $fields)) {
404 if ($field eq "metadata") {
405 $all_metadata_specified = 1;
406 }
407 else {
408 push(@all_fields,$field);
409 }
410 }
411 }
412 }
413
414 if ($all_metadata_specified) {
415
416 # (Unforunately) we need to process all the documents in the collection
417 # to figure out what the metadata_field_mapping is
418
419 # set up the document processr
420 $self->{'buildproc'}->set_output_handle (undef);
421 $self->{'buildproc'}->set_mode ('index_field_mapping');
422 $self->{'buildproc'}->reset();
423
424 &plugin::begin($self->{'pluginfo'}, $self->{'source_dir'},
425 $self->{'buildproc'}, $self->{'maxdocs'});
426 &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
427 "", {}, {}, $self->{'buildproc'}, $self->{'maxdocs'}, 0, $self->{'gli'});
428 &plugin::end($self->{'pluginfo'});
429
430 }
431
432 else {
433 # Field mapping solely dependent of entries in 'indexes'
434
435 # No need to explicitly handle "allfields" as create_shortname()
436 # will get a fix on it through it's static_indexfield_map
437
438 my $buildproc = $self->{'buildproc'};
439
440 foreach my $field (@all_fields)
441 {
442 if (!defined $buildproc->{'indexfieldmap'}->{$field})
443 {
444 my $shortname = '';
445 if (defined $buildproc->{'fieldnamemap'}->{$field})
446 {
447 $shortname = $buildproc->{'fieldnamemap'}->{$field};
448 }
449 else
450 {
451 $shortname = $buildproc->create_shortname($field);
452 }
453 $buildproc->{'indexfieldmap'}->{$field} = $shortname;
454 $buildproc->{'indexfieldmap'}->{$shortname} = 1;
455 }
456 }
457 }
458
459 # Write out solr 'schema.xml' (and related) file
460 #
461 $self->make_final_field_list();
462 $self->premake_solr_auxiliary_files();
463
464 # Now update the solr-core information in solr.xml
465 # => at most two cores <colname>-Doc and <colname>-Sec
466
467 my $site = $self->{'site'};
468 my $collect = $self->{'collection'};
469 my $core_prefix = (defined $site) ? "$site-$collect" : $collect;
470
471 # my $idx = $self->{'index_mapping'}->{$index};
472 my $idx = "idx";
473
474 my $build_dir = $self->{'build_dir'};
475
476 foreach my $level (keys %{$self->{'levels'}}) {
477
478 my ($pindex) = $level =~ /^(.)/;
479
480 my $index_dir = $pindex.$idx;
481 my $core = "$core_prefix-$index_dir";
482
483 # force_removeold == opposite of being run in 'incremental' mode
484 my $force_removeold = ($self->{'incremental'}) ? 0 : 1;
485
486 if ($force_removeold) {
487 print $outhandle "\n-removeold set (new index will be created)\n";
488
489 # create cores under temporary core names, corresponding to building directory
490 $core = "building-".$core;
491
492 my $full_index_dir = &FileUtils::filenameConcatenate($build_dir,$index_dir);
493 &FileUtils::removeFilesRecursive($full_index_dir);
494 &FileUtils::makeDirectory($full_index_dir);
495
496 my $full_tlog_dir = &FileUtils::filenameConcatenate($full_index_dir, "tlog");
497 &FileUtils::makeDirectory($full_tlog_dir);
498
499 # Solr then wants an "index" folder within this general index area!
500# my $full_index_index_dir = &FileUtils::filenameConcatenate($full_index_dir,"index");
501# &FileUtils::makeDirectory($full_index_index_dir);
502
503
504 # now go on and create new index
505 print $outhandle "Creating Solr core: $core\n";
506 $solr_server->admin_create_core($core);
507
508 }
509 else {
510 # if collect==core already in solr.xml (check with STATUS)
511 # => use RELOAD call to refresh fields now expressed in schema.xml
512 #
513 # else
514 # => use CREATE API to add to solr.xml
515
516 my $check_core_exists = $solr_server->admin_ping_core($core);
517
518 if ($check_core_exists) {
519 print $outhandle "Reloading Solr core: $core\n";
520 $solr_server->admin_reload_core($core);
521 }
522 else {
523 print $outhandle "Creating Solr core: $core\n";
524 $solr_server->admin_create_core($core);
525 }
526 }
527 }
528
529}
530
531# Essentially the same as the lucenebuilder.pm version, only using solr_passes
532# => refactor and make better use of inheritence
533
534sub build_index {
535 my $self = shift (@_);
536 my ($index,$llevel) = @_;
537 my $outhandle = $self->{'outhandle'};
538 my $build_dir = $self->{'build_dir'};
539
540 # get the full index directory path and make sure it exists
541 my $indexdir = $self->{'index_mapping'}->{$index};
542 &FileUtils::makeAllDirectories(&FileUtils::filenameConcatenate($build_dir, $indexdir));
543
544 # Find the perl script to call to run solr
545 my $solr_passes = $self->{'solr_passes'};
546 my $solr_passes_exe = $self->{'solr_passes_exe'};
547
548 # define the section names for solrpasses
549 # define the section names and possibly the doc name for solrpasses
550 my $solr_passes_sections = $llevel;
551
552 my $osextra = "";
553 if ($ENV{'GSDLOS'} =~ /^windows$/i) {
554 $build_dir =~ s@/@\\@g;
555 } else {
556 if ($outhandle ne "STDERR") {
557 # so solr_passes doesn't print to stderr if we redirect output
558 $osextra .= " 2>/dev/null";
559 }
560 }
561
562 # get the index expression if this index belongs
563 # to a subcollection
564 my $indexexparr = [];
565 my $langarr = [];
566
567 # there may be subcollection info, and language info.
568 my ($fields, $subcollection, $language) = split (":", $index);
569 my @subcollections = ();
570 @subcollections = split /,/, $subcollection if (defined $subcollection);
571
572 foreach $subcollection (@subcollections) {
573 if (defined ($self->{'collect_cfg'}->{'subcollection'}->{$subcollection})) {
574 push (@$indexexparr, $self->{'collect_cfg'}->{'subcollection'}->{$subcollection});
575 }
576 }
577
578 # add expressions for languages if this index belongs to
579 # a language subcollection - only put languages expressions for the
580 # ones we want in the index
581 my @languages = ();
582 my $languagemetadata = "Language";
583 if (defined ($self->{'collect_cfg'}->{'languagemetadata'})) {
584 $languagemetadata = $self->{'collect_cfg'}->{'languagemetadata'};
585 }
586 @languages = split /,/, $language if (defined $language);
587 foreach my $language (@languages) {
588 my $not=0;
589 if ($language =~ s/^\!//) {
590 $not = 1;
591 }
592 if($not) {
593 push (@$langarr, "!$language");
594 } else {
595 push (@$langarr, "$language");
596 }
597 }
598
599 # Build index dictionary. Uses verbatim stem method
600 print $outhandle "\n creating index dictionary (solr_passes -I1)\n" if ($self->{'verbosity'} >= 1);
601 print STDERR "<Phase name='CreatingIndexDic'/>\n" if $self->{'gli'};
602 my ($handle);
603
604 if ($self->{'debug'}) {
605 $handle = *STDOUT;
606 } else {
607 my $site = $self->{'site'};
608 my $collect = $self->{'collection'};
609 my $core_prefix = (defined $site) ? "$site-$collect" : $collect;
610 my $ds_idx = $self->{'index_mapping'}->{$index};
611 my $core = "$core_prefix-$ds_idx";
612
613 $core = "building-".$core unless $self->{'incremental'}; # core points to building only for force_removeold
614
615 print STDERR "Cmd: $solr_passes_exe $core index \"$build_dir\" \"$indexdir\" $osextra\n";
616 if (!open($handle, "| $solr_passes_exe $core index \"$build_dir\" \"$indexdir\" $osextra")) {
617 print STDERR "<FatalError name='NoRunSolrPasses'/>\n</Stage>\n" if $self->{'gli'};
618 die "solrbuilder::build_index - couldn't run $solr_passes_exe\n!$\n";
619 }
620 }
621
622 my $store_levels = $self->{'levels'};
623 my $db_level = "section"; #always
624 my $dom_level = "";
625 foreach my $key (keys %$store_levels) {
626 if ($mgppbuilder::level_map{$key} eq $llevel) {
627 $dom_level = $key;
628 }
629 }
630 if ($dom_level eq "") {
631 print STDERR "Warning: unrecognized tag level $llevel\n";
632 $dom_level = "document";
633 }
634
635 my $local_levels = { $dom_level => 1 }; # work on one level at a time
636
637 # set up the document processr
638 $self->{'buildproc'}->set_output_handle ($handle);
639 $self->{'buildproc'}->set_mode ('text');
640 $self->{'buildproc'}->set_index ($index, $indexexparr);
641 $self->{'buildproc'}->set_index_languages ($languagemetadata, $langarr) if (defined $language);
642 $self->{'buildproc'}->set_indexing_text (1);
643 #$self->{'buildproc'}->set_indexfieldmap ($self->{'indexfieldmap'});
644 $self->{'buildproc'}->set_levels ($local_levels);
645 if (defined $self->{'collect_cfg'}->{'sortfields'}) {
646 $self->{'buildproc'}->set_sortfields ($self->{'collect_cfg'}->{'sortfields'});
647 }
648 if (defined $self->{'collect_cfg'}->{'facetfields'}) {
649 $self->{'buildproc'}->set_facetfields ($self->{'collect_cfg'}->{'facetfields'});
650 }
651 $self->{'buildproc'}->set_db_level($db_level);
652 $self->{'buildproc'}->reset();
653
654 print $handle "<update>\n";
655
656 &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
657 "", {}, {}, $self->{'buildproc'}, $self->{'maxdocs'}, 0, $self->{'gli'});
658
659 print $handle "</update>\n";
660
661 close ($handle) unless $self->{'debug'};
662
663 $self->print_stats();
664
665 $self->{'buildproc'}->set_levels ($store_levels);
666 print STDERR "</Stage>\n" if $self->{'gli'};
667
668}
669
670
671sub post_build_indexes {
672 my $self = shift(@_);
673
674 # deliberately override to prevent the mgpp post_build_index() calling
675 # $self->make_final_field_list()
676 # as this has been done in our pre_build_indexes() phase for solr
677
678
679 # Also need to stop the Solr/jetty server if it was explicitly started
680 # in pre_build_indexes()
681
682 my $solr_server = $self->{'solr_server'};
683
684 if ($solr_server->explicitly_started()) {
685 $solr_server->stop();
686 }
687
688 $self->{'solr_server'} = undef;
689
690}
691
692sub build_cfg_extra {
693 my $self = shift (@_);
694 my ($build_cfg) = @_;
695
696 $self->lucenebuilder::build_cfg_extra($build_cfg);
697
698 # need to add in facet stuff
699 my @facetfields = ();
700 my @facetfieldmap = ();
701
702 foreach my $sf (@{$self->{'buildproc'}->{'facetfields'}}) {
703 if ($sf eq "rank") {
704 push(@facetfields, $sf);
705 } elsif ($self->{'buildproc'}->{'actualsortfields'}->{$sf}) {
706 my $shortname = $self->{'buildproc'}->{'sortfieldnamemap'}->{$sf};
707 push(@facetfields, $shortname);
708 push (@facetfieldmap, "$sf\-\>$shortname");
709 }
710
711 }
712 $build_cfg->{'indexfacetfields'} = \@facetfields;
713 $build_cfg->{'indexfacetfieldmap'} = \@facetfieldmap;
714}
7151;
716
717
Note: See TracBrowser for help on using the repository browser.