Index: /gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm
===================================================================
--- /gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm	(revision 33326)
+++ /gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm	(revision 33327)
@@ -207,8 +207,8 @@
 # build_cfg as, unlike in MGPP, we need these mappings in advance to configure
 # Lucene/Solr. Unfortunately the original function found in mgbuilder.pm makes
-# a mess of this - it only output fields that have been processed (none have)
+# a mess of this - it only outputs fields that have been processed (none have)
 # and it has a hardcoded renaming for 'text' so it becomes 'TX' according to
 # the schema but 'TE' according to XML sent to lucene_passes.pl/solr_passes.pl
-# This version is dumber - just copy them all across verbatum - but works. We
+# This version is dumber - just copy them all across verbatim - but works. We
 # do still need to support the special case of 'allfields'
 sub make_final_field_list
@@ -286,28 +286,63 @@
 		$schema_insert_xml .= "<field name=\"$field\" ";
 
-		if($field eq "LA" || $field eq "LO")
-		{
-			$schema_insert_xml .=   "type=\"location\" ";
+		if($field eq "CD" || $field eq "CS") {
+			# Coordinate and CoordShort meta should not be split but treated as a whole string for searching. So type=string, not type=text_en_splitting			
+			# Can't set to type="location", which uses solr.LatLonType, since type=location fields "must not be multivalued" as per conf/schema.xml.in.
+			# And we can have multiple Coordinate (and multiple CoordShort) meta for one doc, so multivalued=true.
+			# Not certain what to set stored to. As per conf/schema.xml.in, stored=false means "you only need to search on the field but
+			# don't need to return the original value". And they advice to set stored="false" for all fields possible (esp large fields)."
+			# But stored=false makes it not visible in Luke. So setting stored=true as for other fields
+			# TermVector: '"A term vector is a list of the document's terms and their number of occurrences in that documented."
+			# Each document has one term vector which is a list.' (http://makble.com/what-is-term-vector-in-lucene and lucene API for Field.TermVector)
+			# e.g. docA contains, "cat" 5 times, "dog" 10 times. We don't care to treat Coordinate meta as a term: not a "term" occurring
+			# in the doc, and don't care how often a Coordinate occurs in a document.
+			# Consequently, we don't care about term positions and term offsets for Coordinate meta either.
+			
+			$schema_insert_xml .= "type=\"string\" indexed=\"true\" stored=\"true\" multiValued=\"true\" termVectors=\"false\" termPositions=\"false\" termOffsets=\"false\" />\n";
 		}
-#		elsif ($field ne "ZZ" && $field ne "TX")
-#		{
-#			$schema_insert_xml .=   "type=\"string\" ";
-#		}
-		else
-		{
-		    #$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\" ";
+		
+		elsif($field eq "ML") { 
+			# mapLabel: same attributes as for coord meta CD and CS above
+			# mapLabel is also like facets with type="string" to not get tokenized, and multiValued="true" to allow each shape's label to be stored distinctly
+			$schema_insert_xml .= "type=\"string\" indexed=\"true\" stored=\"true\" multiValued=\"true\" termVectors=\"false\" termPositions=\"false\" termOffsets=\"false\" />\n";
+		}
+		
+		else {
+			if($field eq "LT" || $field eq "LO") # full Latitude and Longitude coordinate meta, not the short variants (LatShort/LA and LongShort/LN)
+			{
+				# Latitude and Longitude is being phased out in favour of using Coord meta.
+				# However, if ever returning to using Lat and Lng instead of Coord meta, then the way the Lat Lng meta is currently written out for type="location"
+				# is in the wrong format. Lat and Lng shouldn't get written out separately but as: Lat,Lng
+				# It gets written out in solrbuildproc.pm, I think, so that would be where it needs to be corrected.
+				# For more info on type=location for our solr 4.7.2 or thereabouts, see https://web.archive.org/web/20160312154250/https://wiki.apache.org/solr/SpatialSearchDev
+				# which states:
+				#    When indexing, the format is something like:
+				#       <field name="store_lat_lon">12.34,-123.45</field>
+				#
+				$schema_insert_xml .=   "type=\"location\" ";				
+			}
 			
+			
+	#		elsif ($field ne "ZZ" && $field ne "TX")
+	#		{
+	#			$schema_insert_xml .=   "type=\"string\" ";
+	#		}
+			else
+			{
+				#$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, 
+			# see TermsResponse termResponse = solrResponse.getTermsResponse(); 
+			$schema_insert_xml .=  "indexed=\"true\" stored=\"true\" multiValued=\"true\" termVectors=\"true\" termPositions=\"true\" termOffsets=\"true\" />\n";
 		}
-		# set termVectors=\"true\" when term vectors info is required, 
-		# see TermsResponse termResponse = solrResponse.getTermsResponse(); 
-		$schema_insert_xml .=  "indexed=\"true\" stored=\"true\" multiValued=\"true\" termVectors=\"true\" termPositions=\"true\" termOffsets=\"true\" />\n";
     }
 
Index: /gs3-extensions/solr/trunk/src/perllib/solrbuildproc.pm
===================================================================
--- /gs3-extensions/solr/trunk/src/perllib/solrbuildproc.pm	(revision 33326)
+++ /gs3-extensions/solr/trunk/src/perllib/solrbuildproc.pm	(revision 33327)
@@ -202,5 +202,14 @@
     
 }
-sub create_shortname {
+
+# UNUSED now by default.
+# Georgy overrode the mgppbuildproc::create_shortname() method in commit 32441 to create the method below, to override the inherited
+# behaviour so that create_shortname() worked appropriately for his use cases involving multiple analyzers.
+# As a result, create_shortname() for solr no longer did a lookup into the %mgppbuildproc::static_indexfield_map for registered shortnames.
+# For the rest, this method is a copy mgppbuildproc::create_shortname().
+# But we want the original mgppbuildproc::create_shortname() behaviour restored, as it does the lookups into %static_indexfield_map that's necessary for us.
+# So we've renamed this function to create_shortname_multi_solr_analyzer below so it won't get called as default beahviour any more.
+# Rename to create_shortname() when requiring Georgy's behaviour.
+sub create_shortname_multi_solr_analyzer {
     my $self = shift(@_);
 
@@ -500,25 +509,40 @@
 		
 		if ($section_text ne "") {
-		    $new_text .= "$section_text ";
+			
+			if ($allfields_index) {
+				$allfields_text .= "$section_text ";
+			}
+			
+			# Remove any leading or trailing white space
+			$section_text =~ s/\s+$//;
+			$section_text =~ s/^\s+//;
+			
+			if ($self->{'indexing_text'}) {
+				# add the tag
+				$new_text .= "<field name=\"$shortname\" >$section_text</field>\n";
+			} else {
+				$new_text .= "$section_text ";
+			}
 		}
 		
 		foreach my $item (@metadata_list) {
 		    &ghtml::htmlsafe($item);
-		    $new_text .= "$item ";
-		}
-
-		if ($allfields_index) {
-		    $allfields_text .= $new_text;
-		}
-
-		# Remove any leading or trailing white space
-		$new_text =~ s/\s+$//;
-		$new_text =~ s/^\s+//;
-	
+
+			if ($allfields_index) {
+				$allfields_text .= "$item ";
+			}
+
+			# Remove any leading or trailing white space
+			$item =~ s/\s+$//;
+			$item =~ s/^\s+//;
+			
+			if ($self->{'indexing_text'}) {
+				# add the tag
+				$new_text .= "<field name=\"$shortname\" >$item</field>\n";
+			} else {
+				$new_text .= "$item ";
+			}
+		} # end for loop processing @metadata_list
 		
-		if ($self->{'indexing_text'}) {
-		    # add the tag
-		    $new_text = "<field name=\"$shortname\" >$new_text</field>\n";
-		}
 		# filter the text
 		$new_text = $self->filter_text ($field, $new_text);
@@ -669,10 +693,11 @@
 
 	    foreach my $item (@metadata_list) {
-		&ghtml::htmlsafe($item);
-		
-		$item = "<field name=\"$sf_shortname\">$item</field>\n";
-		# filter the text???
-		$text .= "$item"; # add it to the main text block
-		#print "#### new_text: $item\n";
+			&ghtml::htmlsafe($item);
+			if ($item =~ /\S/) {
+				$item = "<field name=\"$sf_shortname\">$item</field>\n";
+				# filter the text???
+				$text .= "$item"; # add it to the main text block
+				#print "#### new_text: $item\n";
+			}
 	    }
 	    if(scalar @metadata_list > 0) {
Index: /main/trunk/greenstone2/perllib/lucenebuildproc.pm
===================================================================
--- /main/trunk/greenstone2/perllib/lucenebuildproc.pm	(revision 33326)
+++ /main/trunk/greenstone2/perllib/lucenebuildproc.pm	(revision 33327)
@@ -260,21 +260,34 @@
 		
 		if ($section_text ne "") {
-		    $new_text .= "$section_text ";
+		    
+			if ($self->{'allfields_index'}) {
+				$allfields_text .= "$section_text ";
+			}
+			
+			if ($self->{'indexing_text'}) {
+				# add the tag
+				$new_text .= "<$shortname index=\"1\">$section_text</$shortname>";
+				$self->{'allindexfields'}->{$real_field} = 1;
+			} else {
+				$new_text .= "$section_text ";
+			}
 		}
 		
 		foreach my $item (@metadata_list) {
 		    &ghtml::htmlsafe($item);
-		    $new_text .= "$item ";
-		}
-
-		if ($self->{'allfields_index'}) {
-		    $allfields_text .= $new_text;
-		}
-
-		if ($self->{'indexing_text'}) {
-		    # add the tag
-		    $new_text = "<$shortname index=\"1\">$new_text</$shortname>";
-		    $self->{'allindexfields'}->{$real_field} = 1;
-		}
+
+			if ($self->{'allfields_index'}) {
+				$allfields_text .= "$item ";
+			}
+
+			if ($self->{'indexing_text'}) {
+				# add the tag
+				$new_text .= "<$shortname index=\"1\">$item</$shortname>";
+				$self->{'allindexfields'}->{$real_field} = 1;
+			} else {
+				$new_text .= "$item ";
+			}
+		} # end for loop processing @metadata_list
+		
 		# filter the text
 		$new_text = $self->filter_text ($field, $new_text);
@@ -384,14 +397,25 @@
 		push (@metadata_list, @section_metadata);
 	    }
-	    my $new_text = "";
-	    foreach my $item (@metadata_list) {
-		&ghtml::htmlsafe($item);
-		$new_text .= "$item";
-	    }
-	    if ($new_text =~ /\S/) {
-		$new_text = "<$sf_shortname index=\"1\" tokenize=\"0\">$new_text</$sf_shortname>";
-		# filter the text???
-		$text .= "$new_text"; # add it to the main text block
-		$self->{'actualsortfields'}->{$sfield} = 1;
+	    # my $new_text = "";
+	    # foreach my $item (@metadata_list) {
+		# &ghtml::htmlsafe($item);
+		# $new_text .= "$item"; # should be .="$item "; But will be commenting out and rewriting this entire thing, so it doesn't matter
+	    # }
+	    # if ($new_text =~ /\S/) {
+		# $new_text = "<$sf_shortname index=\"1\" tokenize=\"0\">$new_text</$sf_shortname>";
+		# # filter the text???
+		# $text .= "$new_text"; # add it to the main text block
+		# $self->{'actualsortfields'}->{$sfield} = 1;
+	    # }
+		
+		foreach my $item (@metadata_list) {
+			&ghtml::htmlsafe($item);
+			if ($item =~ /\S/) {
+				$item = "<$sf_shortname index=\"1\" tokenize=\"0\">$item</$sf_shortname>";
+				$text .= "$item"; # add it to the main text block
+			}
+		}
+		if(scalar @metadata_list > 0) {
+			$self->{'actualsortfields'}->{$sfield} = 1;
 	    }
 	}
