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 25862)
+++ /gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/service/GS2SolrSearch.java	(revision 25863)
@@ -21,4 +21,5 @@
 // Greenstone classes
 import java.io.File;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -36,4 +37,5 @@
 import org.greenstone.util.GlobalProperties;
 import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
 
 public class GS2SolrSearch extends SharedSoleneGS2FieldSearch
@@ -45,4 +47,6 @@
 	protected HashMap solr_core_cache;
 	protected SolrQueryWrapper solr_src = null;
+
+	protected ArrayList<String> _facets = new ArrayList<String>();
 
 	public GS2SolrSearch()
@@ -57,8 +61,7 @@
 		if (all_solr_cores == null)
 		{
-			// Share one CoreContainer across all sties/collections
+			// Share one CoreContainer across all sites/collections
 			try
 			{
-
 				String gsdl3_home = GlobalProperties.getGSDL3Home();
 				String solr_ext_name = GlobalProperties.getProperty("gsdlext.solr.dirname", "solr");
@@ -79,4 +82,43 @@
 	}
 
+	/** configure this service */
+	public boolean configure(Element info, Element extra_info)
+	{
+		if (!super.configure(info, extra_info))
+		{
+			return false;
+		}
+
+		Element searchElem = (Element) GSXML.getChildByTagName(extra_info, GSXML.SEARCH_ELEM);
+		NodeList configIndexElems = searchElem.getElementsByTagName(GSXML.INDEX_ELEM);
+
+		ArrayList<String> chosenFacets = new ArrayList<String>();
+		for (int i = 0; i < configIndexElems.getLength(); i++)
+		{
+			Element current = (Element) configIndexElems.item(i);
+			if (current.getAttribute(GSXML.FACET_ATT).equals("true"))
+			{
+				chosenFacets.add(current.getAttribute(GSXML.NAME_ATT));
+			}
+		}
+		
+		Element indexListElem = (Element) GSXML.getChildByTagName(info, GSXML.INDEX_ELEM + GSXML.LIST_MODIFIER);
+		NodeList buildIndexElems = indexListElem.getElementsByTagName(GSXML.INDEX_ELEM);
+
+		for(int j = 0; j < buildIndexElems.getLength(); j++)
+		{
+			Element current = (Element) buildIndexElems.item(j);
+			for(int i = 0; i < chosenFacets.size(); i++)
+			{
+				if (current.getAttribute(GSXML.NAME_ATT).equals(chosenFacets.get(i)))
+				{
+					_facets.add(current.getAttribute(GSXML.SHORTNAME_ATT));
+				}
+			}
+		}
+		
+		return true;
+	}
+
 	public void cleanUp()
 	{
@@ -91,5 +133,11 @@
 	protected boolean setUpQueryer(HashMap params)
 	{
-		String indexdir = GSFile.collectionBaseDir(this.site_home, this.cluster_name) + File.separatorChar + "index" + File.separatorChar;
+		this.solr_src.clearFacets();
+		this.solr_src.clearFacetQueries();
+
+		for (int i = 0; i < _facets.size(); i++)
+		{
+			this.solr_src.addFacet(_facets.get(i));
+		}
 
 		String index = "didx";
@@ -119,5 +167,4 @@
 			{
 				start_page = Integer.parseInt(value);
-
 			}
 			else if (name.equals(MATCH_PARAM))
@@ -150,4 +197,17 @@
 					index = "didx";
 				}
+			}
+			else if (name.equals("facets") && value.length() > 0)
+			{
+				String[] facets = value.split(",");
+
+				for (String facet : facets)
+				{
+					this.solr_src.addFacet(facet);
+				}
+			}
+			else if (name.equals("facetQueries") && value.length() > 0)
+			{
+				this.solr_src.addFacetQuery(value);
 			}
 			else if (name.equals(INDEX_SUBCOLLECTION_PARAM))
@@ -190,5 +250,5 @@
 
 		String core_name = site_name + "-" + coll_name + "-" + index;
-
+		
 		EmbeddedSolrServer solr_core = null;
 
@@ -212,26 +272,9 @@
 	protected Object runQuery(String query)
 	{
-
-		/*
-		 * ModifiableSolrParams solrParams = new ModifiableSolrParams();
-		 * solrParams.set("collectionName", myCollection);
-		 * solrParams.set("username", "admin"); solrParams.set("password",
-		 * "password"); solrParams.set("facet", facet); solrParams.set("q",
-		 * query); solrParams.set("start", start); solrParams.set("rows",
-		 * nbDocuments); return server.query(solrParams);
-		 */
-
-		/*
-		 * SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery(query);
-		 * //solrQuery.set("collectionName", myCollection);
-		 * solrQuery.set("username", "admin"); solrQuery.set("password",
-		 * "password"); solrQuery.set("facet", facet);
-		 * solrQuery.setStart(start); solrQuery.setRows(nbDocuments); //return
-		 * server.query(solrQuery);
-		 */
-
 		try
 		{
+			//SharedSoleneQueryResult sqr = this.solr_src.runQuery(query);
 			SharedSoleneQueryResult sqr = this.solr_src.runQuery(query);
+
 			return sqr;
 		}
