portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r967299 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/ components/jetspeed-search/src/main/java/org/apache/jetspeed/search/lucene/ jetspeed-api/src/main/java/org/apache/jet...
Date Fri, 23 Jul 2010 23:08:29 GMT
Author: woonsan
Date: Fri Jul 23 23:08:29 2010
New Revision: 967299

URL: http://svn.apache.org/viewvc?rev=967299&view=rev
Log:
JS2-1198: Adding new search method to allow to set the default search field.
By using this, it's now possible to search only on keywords.

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PortletRegistryService.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/main/java/org/apache/jetspeed/search/lucene/SearchEngineImpl.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/search/SearchEngine.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PortletRegistryService.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PortletRegistryService.java?rev=967299&r1=967298&r2=967299&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PortletRegistryService.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PortletRegistryService.java
Fri Jul 23 23:08:29 2010
@@ -166,6 +166,7 @@ public class PortletRegistryService
     public PortletDefinitionBeanCollection getPortletDefinitions(@Context HttpServletRequest
servletRequest,
                                                                  @Context UriInfo uriInfo,
                                                                  @PathParam("path") List<PathSegment>
pathSegments, 
+                                                                 @QueryParam("keywords")
String keywordsParam, 
                                                                  @QueryParam("query") String
queryParam, 
                                                                  @QueryParam("begin") String
beginIndexParam,
                                                                  @QueryParam("max") String
maxResultsParam)
@@ -194,13 +195,23 @@ public class PortletRegistryService
         pdBeans.setTotalSize(0);
         List<PortletDefinitionBean> pdBeanList = new ArrayList<PortletDefinitionBean>();
         
-        if (!StringUtils.isBlank(queryParam))
+        if (!StringUtils.isBlank(keywordsParam) || !StringUtils.isBlank(queryParam))
         {
             String queryText = 
                 ParsedObject.FIELDNAME_TYPE + ":\"" + ParsedObject.OBJECT_TYPE_PORTLET +
"\" " +
                 "AND NOT " + ParsedObject.FIELDNAME_TYPE + ":\"" + ParsedObject.OBJECT_TYPE_PORTLET_APPLICATION
+ "\" " + 
-                "AND ( " + queryParam + " )";
-            SearchResults searchResults = searchEngine.search(queryText);
+                "AND ( " + (!StringUtils.isBlank(keywordsParam) ? keywordsParam : queryParam)
+ " )";
+            SearchResults searchResults = null;
+            
+            if (!StringUtils.isBlank(keywordsParam))
+            {
+                searchResults = searchEngine.search(queryText, ParsedObject.FIELDNAME_KEYWORDS);
+            }
+            else
+            {
+                searchResults = searchEngine.search(queryText);
+            }
+            
             List<ParsedObject> searchResultList = searchResults.getResults();
             ArrayList<PortletDefinition> searchedPortletDefinitions = new ArrayList<PortletDefinition>();
             

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/main/java/org/apache/jetspeed/search/lucene/SearchEngineImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/main/java/org/apache/jetspeed/search/lucene/SearchEngineImpl.java?rev=967299&r1=967298&r2=967299&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/main/java/org/apache/jetspeed/search/lucene/SearchEngineImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/main/java/org/apache/jetspeed/search/lucene/SearchEngineImpl.java
Fri Jul 23 23:08:29 2010
@@ -495,13 +495,21 @@ public class SearchEngineImpl implements
      */
     public SearchResults search(String queryString)
     {
-        return search(queryString, defaultTopHitsCount);
+        return search(queryString, ParsedObject.FIELDNAME_SYNTHETIC);
     }
     
     /* (non-Javadoc)
-     * @see org.apache.jetspeed.search.SearchEngine#search(java.lang.String)
+     * @see org.apache.jetspeed.search.SearchEngine#search(java.lang.String, java.lang.String)
      */
-    public SearchResults search(String queryString, int topHitsCount)
+    public SearchResults search(String queryString, String defaultFieldName)
+    {
+        return search(queryString, defaultFieldName, defaultTopHitsCount);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.search.SearchEngine#search(java.lang.String, java.lang.String,
int)
+     */
+    public SearchResults search(String queryString, String defaultFieldName, int topHitsCount)
     {
         SearchResults results = null;
         
@@ -513,7 +521,7 @@ public class SearchEngineImpl implements
             indexReader = IndexReader.open(directory);
             searcher = new IndexSearcher(indexReader);
             
-            QueryParser queryParser = new QueryParser(Version.LUCENE_30, ParsedObject.FIELDNAME_SYNTHETIC,
analyzer);
+            QueryParser queryParser = new QueryParser(Version.LUCENE_30, defaultFieldName,
analyzer);
             Query query = queryParser.parse(queryString);
             TopDocs topDocs = searcher.search(query, topHitsCount);
             

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/search/SearchEngine.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/search/SearchEngine.java?rev=967299&r1=967298&r2=967299&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/search/SearchEngine.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/search/SearchEngine.java
Fri Jul 23 23:08:29 2010
@@ -40,5 +40,7 @@ public interface SearchEngine
     
     SearchResults search(String query);
     
-    SearchResults search(String query, int topHitsCount);
+    SearchResults search(String query, String defaultFieldName);
+    
+    SearchResults search(String query, String defaultFieldName, int topHitsCount);
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message