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

Last change on this file since 30050 was 30050, checked in by Georgiy Litvinov, 9 years ago

Solr repo modifications for Solr side highlighing and snippets

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