Index: portal-impl/src/com/liferay/portlet/wiki/util/WikiOpenSearchImpl.java
===================================================================
--- portal-impl/src/com/liferay/portlet/wiki/util/WikiOpenSearchImpl.java	(revisión: 76244)
+++ portal-impl/src/com/liferay/portlet/wiki/util/WikiOpenSearchImpl.java	(copia de trabajo)
@@ -14,7 +14,34 @@
 
 package com.liferay.portlet.wiki.util;
 
+import java.util.Date;
+
+import javax.portlet.PortletMode;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletURL;
+import javax.portlet.WindowState;
+import javax.servlet.http.HttpServletRequest;
+
+import com.liferay.portal.kernel.search.Document;
+import com.liferay.portal.kernel.search.Field;
+import com.liferay.portal.kernel.search.Hits;
 import com.liferay.portal.kernel.search.HitsOpenSearchImpl;
+import com.liferay.portal.kernel.search.Indexer;
+import com.liferay.portal.kernel.search.SearchContext;
+import com.liferay.portal.kernel.search.SearchContextFactory;
+import com.liferay.portal.kernel.search.SearchException;
+import com.liferay.portal.kernel.search.Summary;
+import com.liferay.portal.kernel.util.GetterUtil;
+import com.liferay.portal.kernel.util.Validator;
+import com.liferay.portal.kernel.util.WebKeys;
+import com.liferay.portal.kernel.xml.Element;
+import com.liferay.portal.model.Portlet;
+import com.liferay.portal.service.PortletLocalServiceUtil;
+import com.liferay.portal.theme.ThemeDisplay;
+import com.liferay.portal.util.PortalUtil;
+import com.liferay.portlet.PortletURLFactoryUtil;
+import com.liferay.portlet.ratings.model.RatingsStats;
+import com.liferay.portlet.ratings.service.RatingsStatsLocalServiceUtil;
 
 /**
  * @author Brian Wing Shun Chan
@@ -35,6 +62,130 @@
 
 	public String getTitle(String keywords) {
 		return TITLE + keywords;
-	}
+	}	
+	
+	public String search(
+			HttpServletRequest request, long groupId, long userId,
+			String keywords, int startPage, int itemsPerPage, String format)
+		throws SearchException {
 
+		try {
+			ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
+				WebKeys.THEME_DISPLAY);
+
+			int start = (startPage * itemsPerPage) - itemsPerPage;
+			int end = startPage * itemsPerPage;
+
+			SearchContext searchContext = SearchContextFactory.getInstance(
+				request);
+
+			searchContext.setGroupIds(new long[] {groupId});
+			searchContext.setEnd(end);
+			searchContext.setKeywords(keywords);
+			searchContext.setScopeStrict(false);
+			searchContext.setStart(start);
+			searchContext.setUserId(userId);
+
+			addSearchAttributes(
+				themeDisplay.getCompanyId(), searchContext, keywords);
+
+			Portlet portlet = PortletLocalServiceUtil.getPortletById(
+				themeDisplay.getCompanyId(), getPortletId());
+
+			Indexer indexer = portlet.getIndexerInstance();
+
+			Hits results = indexer.search(searchContext);
+
+			String[] queryTerms = results.getQueryTerms();
+
+			int total = results.getLength();
+
+			Object[] values = addSearchResults(
+				queryTerms, keywords, startPage, itemsPerPage, total, start,
+				getTitle(keywords), getSearchPath(), format, themeDisplay);
+
+			com.liferay.portal.kernel.xml.Document doc =
+				(com.liferay.portal.kernel.xml.Document)values[0];
+			Element root = (Element)values[1];
+
+			for (int i = 0; i < results.getDocs().length; i++) {
+				Document result = results.doc(i);
+
+				String portletId = result.get(Field.PORTLET_ID);
+
+				String snippet = results.snippet(i);
+
+				long resultGroupId = GetterUtil.getLong(
+					result.get(Field.GROUP_ID));
+				
+				long scopeGroupId=GetterUtil.getLong(
+						result.get(Field.SCOPE_GROUP_ID));
+				
+				
+				long plid=0;			
+				
+				
+				if (scopeGroupId>0 ){
+					if (resultGroupId!=scopeGroupId) {						
+						resultGroupId=scopeGroupId;
+					}
+				}			
+				
+				plid=PortalUtil.getPlidFromPortletId(resultGroupId, portletId);				
+								
+				PortletURL portletURL = PortletURLFactoryUtil.create(
+						request, portletId, plid, PortletRequest.RENDER_PHASE);
+				portletURL.setWindowState(WindowState.MAXIMIZED);
+				portletURL.setPortletMode(PortletMode.VIEW);			
+				
+
+				Summary summary = getSummary(
+					indexer, result, snippet, portletURL);
+
+				String title = summary.getTitle();
+				String url = getURL(
+						themeDisplay, resultGroupId, result, portletURL);
+				Date modifedDate = result.getDate(Field.MODIFIED);
+				String content = summary.getContent();
+
+				String[] tags = new String[0];
+
+				Field assetTagNamesField = result.getFields().get(
+					Field.ASSET_TAG_NAMES);
+
+				if (assetTagNamesField != null) {
+					tags = assetTagNamesField.getValues();
+				}
+
+				double ratings = 0.0;
+
+				String entryClassName = result.get(Field.ENTRY_CLASS_NAME);
+				long entryClassPK = GetterUtil.getLong(
+					result.get(Field.ENTRY_CLASS_PK));
+
+				if ((Validator.isNotNull(entryClassName)) &&
+					(entryClassPK > 0)) {
+
+					RatingsStats stats = RatingsStatsLocalServiceUtil.getStats(
+						entryClassName, entryClassPK);
+
+					ratings = stats.getTotalScore();
+				}
+
+				double score = results.score(i);
+
+				addSearchResult(
+					root, resultGroupId, entryClassName, entryClassPK, title,
+					url, modifedDate, content, tags, ratings, score, format);
+			}
+			
+
+			return doc.asXML();
+		}
+		catch (Exception e) {
+			throw new SearchException(e);
+		}
+	}	
+	
+
 }
\ No newline at end of file
