Changeset 29176

Show
Ignore:
Timestamp:
08.08.2014 16:57:34 (5 years ago)
Author:
ak19
Message:

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.

Files:
2 modified

Legend:

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

    r29170 r29176  
    282282    foreach my $ifm (@{$self->{'build_cfg'}->{'indexfieldmap'}}) { 
    283283 
    284         my ($field) = ($ifm =~ m/^.*->(.*)$/); 
     284        my ($fullfieldname, $field) = ($ifm =~ m/^(.*)->(.*)$/); 
    285285 
    286286        $schema_insert_xml .= "    "; # indent 
     
    297297        else 
    298298        { 
    299             $schema_insert_xml .= "type=\"text_en_splitting\" "; 
     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             
    300309        } 
    301310        # set termVectors=\"true\" when term vectors info is required,  
  • main/trunk/greenstone2/perllib/collConfigxml.pm

    r28034 r29176  
    5353           "defaultIndexLanguage" => "defaultlanguage", 
    5454           "index" => "indexes", 
     55           "indexfieldoptions" => "indexfieldoptions", 
    5556           "sort" => "sortfields", 
    5657           "facet" => "facetfields",  
     
    8687# ("plugin", "option") 
    8788my $currentIndex = 0; 
    88 my $arrayexp = q/^(index|sort|facet|level|indexOption|indexSubcollection|indexLanguage|orthogonalBuildTypes)$/;  
     89 
     90my $structexp = q/^(index)$/; 
     91# structexp contains a hashmap of option(name, value) pairs per index name like allfields/ZZ or titles/TI 
     92# e.g. <index name="allfields"> 
     93#    <displayItem ... /> 
     94#    <option name="solrfieldtype" value="text_ja" /> 
     95#      </index> 
     96 
     97my $arrayexp = q/^(sort|facet|level|indexOption|indexSubcollection|indexLanguage|orthogonalBuildTypes)$/;  
     98#my $arrayexp = q/^(index|sort|facet|level|indexOption|indexSubcollection|indexLanguage|orthogonalBuildTypes)$/;  
    8999my $arrayarrayexp = q/^(plugin|classifier)$/; #|buildOption)$/; 
    90100my $hashexp = q/^(subcollection)$/; # add other element names that should be represented by hash expressions here 
     
    199209    #} 
    200210  
    201     #@ Handle index|sort|facet|level|indexOption|indexSubcollection|indexLanguage  
     211    #@ Handle sort|facet|level|indexOption|indexSubcollection|indexLanguage  
    202212    elsif ($element =~ /$arrayexp/) { 
    203213      my $key = $nameMap->{$element};   #  
     
    210220      } 
    211221    } 
     222 
     223    #@ Handle index which can have options as children to be put in a map: <option name="name" value="value" /> 
     224    elsif ($element =~ /$structexp/) { 
     225    # find the gs2 mapping name 
     226        $currentLevel = $element; 
     227     
     228    # for GS2, 'indexes' should be an arrayexp, so maintain that part of the code as it is   
     229    my $key = $nameMap->{$element}; # 'indexes' 
     230    if (!defined $data->{$key}) { 
     231        $data->{$key} = [];      
     232    } 
     233     
     234    if (defined $name) { 
     235        push (@{$data->{$key}},$name);       
     236    } 
     237    } 
     238 
     239    #@ Handling the option elements in each index structure, if any, only for GS2 
     240    elsif ($currentLevel =~ /$structexp/ && $element eq "option") { 
     241    # find the gs2 mapping name for classifier and plugin 
     242    my $key = $nameMap->{$currentLevel."fieldoptions"}; # my $key = $currentLevel."fieldoptions"; # indexfieldoptions  
     243 
     244    # The last element of the 'indexes' array contains the name of the index currently being processed 
     245    # e.g. "allfields" 
     246    my $indexKey = $nameMap->{$currentLevel}; # 'indexes' 
     247    my $arrSize = scalar( @{$data->{$indexKey}} ); # length of 'indexes' array 
     248    my $indexName = @{$data->{$indexKey}}[$arrSize-1]; # name of index currently being processed in prev elsif 
     249 
     250    if (!defined $data->{$key}) { 
     251        $data->{$key} = {}; # 'indexoptions' is a new hashmap 
     252    }    
     253    if (defined $name and $name =~ /\w/ && defined $value and $value =~ /\w/) { 
     254        # we have a name and value to this option, add them as options associated with the current index 
     255         
     256        if (!defined $data->{$key}->{$indexName}) { 
     257        $data->{$key}->{$indexName} = {}; # indexoptions -> allfields is a new hashmap 
     258        } 
     259         
     260        $data->{$key}->{$indexName}->{$name} = $value; 
     261         
     262        #print STDERR "@@@ Found: Value: data->{'indexfieldoptions'}->{$indexName}->{$name}: " . $data->{'indexfieldoptions'}->{$indexName}->{$name} . "\n";         
     263    } 
     264    } 
     265 
    212266    # importOption and buildOption, just stored at top level, name=value,  
    213267    # as per gs2 version