Index: gs3-extensions/solr/trunk/src/conf/schema.xml.in
===================================================================
--- gs3-extensions/solr/trunk/src/conf/schema.xml.in	(revision 30036)
+++ gs3-extensions/solr/trunk/src/conf/schema.xml.in	(revision 30050)
@@ -478,4 +478,5 @@
     <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
       <analyzer type="index">
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
@@ -500,4 +501,5 @@
     <fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
       <analyzer type="index">
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <!-- in this example, we will only use synonyms at query time
@@ -548,4 +550,5 @@
     <fieldType name="text_en_splitting" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
       <analyzer type="index">
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.WhitespaceTokenizerFactory"/>
         <!-- in this example, we will only use synonyms at query time
@@ -583,4 +586,5 @@
     <fieldType name="text_en_splitting_tight" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
       <analyzer>
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.WhitespaceTokenizerFactory"/>
         <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>
@@ -762,4 +766,5 @@
     <fieldType name="text_ar" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <!-- for any non-arabic -->
@@ -775,4 +780,5 @@
     <fieldType name="text_bg" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/> 
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -785,4 +791,5 @@
     <fieldType name="text_ca" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <!-- removes l', etc -->
@@ -797,4 +804,5 @@
     <fieldType name="text_cjk" class="solr.TextField" positionIncrementGap="100">
       <analyzer>
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <!-- normalize width before bigram, as e.g. half-width dakuten combine  -->
@@ -809,4 +817,5 @@
     <fieldType name="text_ckb" class="solr.TextField" positionIncrementGap="100">
       <analyzer>
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.SoraniNormalizationFilterFactory"/>
@@ -821,4 +830,5 @@
     <fieldType name="text_cz" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -831,4 +841,5 @@
     <fieldType name="text_da" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -841,4 +852,5 @@
     <fieldType name="text_de" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -854,4 +866,5 @@
     <fieldType name="text_el" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <!-- greek specific lowercase for sigma -->
@@ -865,4 +878,5 @@
     <fieldType name="text_es" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -876,4 +890,5 @@
     <fieldType name="text_eu" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -887,4 +902,5 @@
       <analyzer>
         <!-- for ZWNJ -->
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <charFilter class="solr.PersianCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
@@ -899,4 +915,5 @@
     <fieldType name="text_fi" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -910,4 +927,5 @@
     <fieldType name="text_fr" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <!-- removes l', etc -->
@@ -924,4 +942,5 @@
     <fieldType name="text_ga" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <!-- removes d', etc -->
@@ -938,4 +957,5 @@
     <fieldType name="text_gl" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -949,4 +969,5 @@
     <fieldType name="text_hi" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -963,4 +984,5 @@
     <fieldType name="text_hu" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -974,4 +996,5 @@
     <fieldType name="text_hy" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -984,4 +1007,5 @@
     <fieldType name="text_id" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -995,4 +1019,5 @@
     <fieldType name="text_it" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <!-- removes l', etc -->
@@ -1041,4 +1066,5 @@
            See http://wiki.apache.org/solr/JapaneseLanguageSupport for more on Japanese language support.
         -->
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.JapaneseTokenizerFactory" mode="search"/>
         <!--<tokenizer class="solr.JapaneseTokenizerFactory" mode="search" userDictionary="lang/userdict_ja.txt"/>-->
@@ -1061,4 +1087,5 @@
     <fieldType name="text_lv" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -1071,4 +1098,5 @@
     <fieldType name="text_nl" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -1082,4 +1110,5 @@
     <fieldType name="text_no" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -1095,4 +1124,5 @@
     <fieldType name="text_pt" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -1108,4 +1138,5 @@
     <fieldType name="text_ro" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -1118,4 +1149,5 @@
     <fieldType name="text_ru" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -1127,10 +1159,11 @@
 	<!-- Russian with morphology-->
     <fieldType name="text_ru_morph" class="solr.TextField" positionIncrementGap="100">
-          <analyzer>
-          <tokenizer class="solr.StandardTokenizerFactory"/>
-          <filter class="solr.LowerCaseFilterFactory"/>
-          <filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_ru.txt" format="snowball" />
-          <filter class="org.apache.lucene.morphology.russian.RussianFilterFactory"/>
-          </analyzer>
+      <analyzer>
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
+        <tokenizer class="solr.StandardTokenizerFactory"/>
+        <filter class="solr.LowerCaseFilterFactory"/>
+        <filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_ru.txt" format="snowball" />
+        <filter class="org.apache.lucene.morphology.russian.RussianFilterFactory"/>
+      </analyzer>
     </fieldType>
  
@@ -1138,4 +1171,5 @@
     <fieldType name="text_sv" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -1149,4 +1183,5 @@
     <fieldType name="text_th" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
@@ -1159,4 +1194,5 @@
     <fieldType name="text_tr" class="solr.TextField" positionIncrementGap="100">
       <analyzer> 
+	<charFilter class="solr.HTMLStripCharFilterFactory"/>
         <tokenizer class="solr.StandardTokenizerFactory"/>
         <filter class="solr.TurkishLowerCaseFilterFactory"/>
Index: gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm
===================================================================
--- gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm	(revision 30036)
+++ gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm	(revision 30050)
@@ -310,5 +310,5 @@
 		# see TermsResponse termResponse = solrResponse.getTermsResponse(); 
 		#$schema_insert_xml .=  "indexed=\"true\" stored=\"false\" termVectors=\"true\" multiValued=\"true\" />\n";
-		$schema_insert_xml .=  "indexed=\"true\" stored=\"false\" multiValued=\"true\" />\n";
+		$schema_insert_xml .=  "indexed=\"true\" stored=\"true\" multiValued=\"true\" />\n";
                 #$schema_insert_xml .=  "indexed=\"true\" stored=\"true\" multiValued=\"true\" />\n";
     }
Index: gs3-extensions/solr/trunk/src/perllib/solrbuildproc.pm
===================================================================
--- gs3-extensions/solr/trunk/src/perllib/solrbuildproc.pm	(revision 30036)
+++ gs3-extensions/solr/trunk/src/perllib/solrbuildproc.pm	(revision 30050)
@@ -430,5 +430,6 @@
 			if ($self->{'indexing_text'}) {
 			    # we always strip html
-			    $section_text = $self->preprocess_text($section_text, 1, "");
+			    &ghtml::htmlsafe($section_text);
+			    #$section_text = $self->preprocess_text($section_text, 1, "");
 			}
 			else { 
Index: gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/service/GS2SolrSearch.java
===================================================================
--- gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/service/GS2SolrSearch.java	(revision 30036)
+++ gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/service/GS2SolrSearch.java	(revision 30050)
@@ -65,4 +65,6 @@
                 paramDefaults.put(SORT_ORDER_PARAM, SORT_ORDER_DESCENDING);
 		does_faceting = true;
+		does_highlight_snippets = true;
+		does_full_field_highlighting = true;
 		// Used to store the solr cores that match the required 'level' 
 		// of search (e.g. either document-level=>didx, or 
@@ -341,4 +343,11 @@
 		try
 		{
+			//if it is a Highlighting Query - execute it
+			this.solr_src.setHighlightField(indexField);
+			if(hldocOID != null)
+			{
+				String rslt = this.solr_src.runHighlightingQuery(query,hldocOID);
+				return rslt;
+			}
 			SharedSoleneQueryResult sqr = this.solr_src.runQuery(query);
 
@@ -352,5 +361,6 @@
 		return null;
 	}
-
+	
+	
 	/** get the total number of docs that match */
 	protected long numDocsMatched(Object query_result)
@@ -445,4 +455,16 @@
 
 		return newFacetList;
+	}
+	@Override
+	protected Map<String, Map<String, List<String>>> getHighlightSnippets(Object query_result)
+	{
+		if (!(query_result instanceof SolrQueryResult))
+		{
+			return null;
+		}
+
+		SolrQueryResult result = (SolrQueryResult) query_result;
+		
+		return result.getHighlightResults();
 	}
 
Index: gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/util/SolrQueryResult.java
===================================================================
--- gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/util/SolrQueryResult.java	(revision 30036)
+++ gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/util/SolrQueryResult.java	(revision 30050)
@@ -28,4 +28,5 @@
 
 import java.util.List;
+import java.util.Map;
 
 import org.apache.solr.client.solrj.response.FacetField;
@@ -41,9 +42,9 @@
 {
 	protected List<FacetField> _facetResults = null;
+	protected Map<String,Map<String,List<String>>> _highlightResults = null;
 	SolrQueryResult()
 	{
 		super();
 	}
-	
 	public void setFacetResults(List<FacetField> facetResults)
 	{
@@ -55,3 +56,12 @@
 		return _facetResults;
 	}
+	//Save highlighting snippets
+	public void setHighlightResults(Map<String,Map<String,List<String>>> highlightResults){
+		_highlightResults = highlightResults;
+	}
+	//Extract highlighting snippets
+	public Map<String,Map<String,List<String>>> getHighlightResults(){
+		return _highlightResults;
+	}
+	
 }
Index: gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/util/SolrQueryWrapper.java
===================================================================
--- gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/util/SolrQueryWrapper.java	(revision 30036)
+++ gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/util/SolrQueryWrapper.java	(revision 30050)
@@ -33,7 +33,7 @@
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.HashSet;
-
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
@@ -46,8 +46,6 @@
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.client.solrj.response.TermsResponse;
-
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrCore;
-
 import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrDocumentList;
@@ -55,5 +53,4 @@
 import org.greenstone.LuceneWrapper4.SharedSoleneQuery;
 import org.greenstone.LuceneWrapper4.SharedSoleneQueryResult;
-
 import org.apache.lucene.search.Query; // Query, TermQuery, BooleanQuery, BooleanClause and more
 import org.apache.lucene.index.IndexReader;
@@ -81,4 +78,6 @@
 	SolrServer solr_core = null;
 
+	protected String highlight_field = null;
+	
     String collection_core_name_prefix = null;
 
@@ -109,5 +108,8 @@
     }
   }
-
+  public void setHighlightField(String hl_field)
+  {
+    this.highlight_field = hl_field;
+  }
   public void setSortOrder(String order)
   {
@@ -360,4 +362,14 @@
 		solrQuery.setFields("docOID", "score"); //solrParams.set("fl", "docOID score totaltermfreq(field,'queryterm')"); 
 		
+		//Turn on highlighting
+		solrQuery.setHighlight(true);
+		//Return 3 snippets for each document
+		solrQuery.setParam("hl.snippets", "3");
+		solrQuery.setParam("hl.fl", highlight_field);
+		solrQuery.setHighlightSimplePre("&lt;span class=\"snippetText\"&gt;");
+		
+		//Set text which appears after highlighted term
+		solrQuery.setHighlightSimplePost("&lt;/span&gt;");
+		
 		//solrQuery.setTerms(true); // turn on the termsComponent		
 		//solrQuery.set("terms.fl", "ZZ"); // which field to get the terms from. ModifiableSolrParams method
@@ -392,4 +404,6 @@
 			QueryResponse solrResponse = solr_core.query(solrQuery); //solr_core.query(solrParams);
 			SolrDocumentList hits = solrResponse.getResults();
+			Map<String, Map<String, List<String>>> hlResponse = solrResponse.getHighlighting();
+			solr_query_result.setHighlightResults(hlResponse);
 			//TermsResponse termResponse = solrResponse.getTermsResponse(); // null unless termvectors=true in schema.xml
 
@@ -410,6 +424,5 @@
 				solr_query_result.setStartResults(start_results);
 				solr_query_result.setEndResults(start_results + hits.size());
-
-				
+					
 				// get the first field we're searching in, this will be the fallback field
 				int sepIndex = query_string.indexOf(":");
@@ -505,4 +518,57 @@
 		return solr_query_result;
 	}
+// Highlighting query. Returns full highlighted text for document
+	public String runHighlightingQuery(String query,String hldocOID)
+	{
+					
+		SolrQueryResult solr_query_result = new SolrQueryResult();
+		solr_query_result.clear();
+
+		
+		/* Create Query*/
+		
+		SolrQuery solrQuery = new SolrQuery(query);
+		
+		/* Set Query Parameters*/
+		
+		//Turn on highlighting
+		solrQuery.setHighlight(true);
+		//Extract default field from query
+		
+		//Set field for highlighting
+		solrQuery.setParam("hl.fl", highlight_field);
+		
+		//Get whole highlighted field
+		solrQuery.setHighlightFragsize(0);
+		
+		//Return only required document by docOID
+		solrQuery.setFilterQueries("docOID:"+ hldocOID);
+		
+		//Set text which appears before highlighted term
+		//solrQuery.setHighlightSimplePre("<annotation type=\"query_term\">");
+		solrQuery.setHighlightSimplePre("<span class=\"termHighlight\">");
+		//Set text which appears after highlighted term
+		//solrQuery.setHighlightSimplePost("</annotation>");
+		solrQuery.setHighlightSimplePost("</span>");
+		//Prepare results
+		String text = null;
+		// do the query
+		try
+		{
+			QueryResponse solrResponse = solr_core.query(solrQuery); //solr_core.query(solrParams);
+			//Get highliting results
+			Map<String,Map<String,List<String>>> highlightingResults = solrResponse.getHighlighting();
+			//Get highlited document text
+			text = highlightingResults.get(hldocOID).get(highlight_field).get(0);
+			
+												
+		}
+		catch (SolrServerException server_exception)
+		{
+			server_exception.printStackTrace();
+			
+		}
+		return text;
+	}
 
 	//Greenstone universe operates with a base of 1 for "start_results"
