Index: /gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm
===================================================================
--- /gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm	(revision 29175)
+++ /gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm	(revision 29176)
@@ -282,5 +282,5 @@
     foreach my $ifm (@{$self->{'build_cfg'}->{'indexfieldmap'}}) {
 
-		my ($field) = ($ifm =~ m/^.*->(.*)$/);
+		my ($fullfieldname, $field) = ($ifm =~ m/^(.*)->(.*)$/);
 
 		$schema_insert_xml .= "    "; # indent
@@ -297,5 +297,14 @@
 		else
 		{
-			$schema_insert_xml .= "type=\"text_en_splitting\" ";
+		    #$schema_insert_xml .= "type=\"text_en_splitting\" ";
+
+		    # original default solr field type for all fields is text_en_splitting
+		    my $solrfieldtype = "text_en_splitting";
+		    if(defined $self->{'collect_cfg'}->{'indexfieldoptions'}->{$fullfieldname}->{'solrfieldtype'}) {	
+			$solrfieldtype = $self->{'collect_cfg'}->{'indexfieldoptions'}->{$fullfieldname}->{'solrfieldtype'};
+			#print STDERR "@@@@#### found TYPE: $solrfieldtype\n";
+		    }
+		    $schema_insert_xml .= "type=\"$solrfieldtype\" ";
+			
 		}
 		# set termVectors=\"true\" when term vectors info is required, 
Index: /main/trunk/greenstone2/perllib/collConfigxml.pm
===================================================================
--- /main/trunk/greenstone2/perllib/collConfigxml.pm	(revision 29175)
+++ /main/trunk/greenstone2/perllib/collConfigxml.pm	(revision 29176)
@@ -53,4 +53,5 @@
 	       "defaultIndexLanguage" => "defaultlanguage",
 	       "index" => "indexes",
+	       "indexfieldoptions" => "indexfieldoptions",
 	       "sort" => "sortfields",
 	       "facet" => "facetfields", 
@@ -86,5 +87,14 @@
 # ("plugin", "option")
 my $currentIndex = 0;
-my $arrayexp = q/^(index|sort|facet|level|indexOption|indexSubcollection|indexLanguage|orthogonalBuildTypes)$/; 
+
+my $structexp = q/^(index)$/;
+# structexp contains a hashmap of option(name, value) pairs per index name like allfields/ZZ or titles/TI
+# e.g. <index name="allfields">
+#	 <displayItem ... />
+#	 <option name="solrfieldtype" value="text_ja" />
+#      </index>
+
+my $arrayexp = q/^(sort|facet|level|indexOption|indexSubcollection|indexLanguage|orthogonalBuildTypes)$/; 
+#my $arrayexp = q/^(index|sort|facet|level|indexOption|indexSubcollection|indexLanguage|orthogonalBuildTypes)$/; 
 my $arrayarrayexp = q/^(plugin|classifier)$/; #|buildOption)$/;
 my $hashexp = q/^(subcollection)$/; # add other element names that should be represented by hash expressions here
@@ -199,5 +209,5 @@
     #}
  
-    #@ Handle index|sort|facet|level|indexOption|indexSubcollection|indexLanguage 
+    #@ Handle sort|facet|level|indexOption|indexSubcollection|indexLanguage 
     elsif ($element =~ /$arrayexp/) {
       my $key = $nameMap->{$element};	# 
@@ -210,4 +220,48 @@
       }
     }
+
+    #@ Handle index which can have options as children to be put in a map: <option name="name" value="value" />
+    elsif ($element =~ /$structexp/) {
+	# find the gs2 mapping name
+        $currentLevel = $element;
+	
+	# for GS2, 'indexes' should be an arrayexp, so maintain that part of the code as it is	
+	my $key = $nameMap->{$element};	# 'indexes'
+	if (!defined $data->{$key}) {
+	    $data->{$key} = [];	    
+	}
+	
+	if (defined $name) {
+	    push (@{$data->{$key}},$name);	    
+	}
+    }
+
+    #@ Handling the option elements in each index structure, if any, only for GS2
+    elsif ($currentLevel =~ /$structexp/ && $element eq "option") {
+	# find the gs2 mapping name for classifier and plugin
+	my $key = $nameMap->{$currentLevel."fieldoptions"}; # my $key = $currentLevel."fieldoptions"; # indexfieldoptions 
+
+	# The last element of the 'indexes' array contains the name of the index currently being processed
+	# e.g. "allfields"
+	my $indexKey = $nameMap->{$currentLevel}; # 'indexes'
+	my $arrSize = scalar( @{$data->{$indexKey}} ); # length of 'indexes' array
+	my $indexName = @{$data->{$indexKey}}[$arrSize-1]; # name of index currently being processed in prev elsif
+
+	if (!defined $data->{$key}) {
+	    $data->{$key} = {}; # 'indexoptions' is a new hashmap
+	}   
+	if (defined $name and $name =~ /\w/ && defined $value and $value =~ /\w/) {
+	    # we have a name and value to this option, add them as options associated with the current index
+	    
+	    if (!defined $data->{$key}->{$indexName}) {
+		$data->{$key}->{$indexName} = {}; # indexoptions -> allfields is a new hashmap
+	    }
+	    
+	    $data->{$key}->{$indexName}->{$name} = $value;
+	    
+	    #print STDERR "@@@ Found: Value: data->{'indexfieldoptions'}->{$indexName}->{$name}: " . $data->{'indexfieldoptions'}->{$indexName}->{$name} . "\n";	    
+	}
+    }
+
     # importOption and buildOption, just stored at top level, name=value, 
     # as per gs2 version
