Author: meric
Date: Tue Feb 26 09:18:53 2013
New Revision: 1450090

URL: http://svn.apache.org/r1450090
Log:
STANBOL-964 SolrQuery parse problem is solved in Contenthub FeaturedSearch

Modified:
    
stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java
    
stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java

Modified: 
stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java
URL: 
http://svn.apache.org/viewvc/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java?rev=1450090&r1=1450089&r2=1450090&view=diff
==============================================================================
--- 
stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java
 (original)
+++ 
stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java
 Tue Feb 26 09:18:53 2013
@@ -130,18 +130,20 @@ public class FeaturedSearchImpl implemen
 
     private List<FacetResult> convertFacetFields(List<FacetField> facetFields, 
List<FacetResult> allFacets) {
         List<FacetResult> facets = new ArrayList<FacetResult>();
-        if (allFacets == null) {
-            for (FacetField facetField : facetFields) {
-                if (facetField.getValues() != null) {
-                    facets.add(new FacetResultImpl(facetField));
+        if (facetFields != null) {
+            if (allFacets == null) {
+                for (FacetField facetField : facetFields) {
+                    if (facetField.getValues() != null) {
+                        facets.add(new FacetResultImpl(facetField));
+                    }
                 }
-            }
-        } else {
-            for (FacetField facetField : facetFields) {
-                if (facetField.getValues() != null) {
-                    for (FacetResult facetResult : allFacets) {
-                        if 
(facetResult.getFacetField().getName().equals(facetField.getName())) {
-                            facets.add(new FacetResultImpl(facetField, 
facetResult.getType()));
+            } else {
+                for (FacetField facetField : facetFields) {
+                    if (facetField.getValues() != null) {
+                        for (FacetResult facetResult : allFacets) {
+                            if 
(facetResult.getFacetField().getName().equals(facetField.getName())) {
+                                facets.add(new FacetResultImpl(facetField, 
facetResult.getType()));
+                            }
                         }
                     }
                 }
@@ -187,7 +189,6 @@ public class FeaturedSearchImpl implemen
         SolrQuery solrQuery = new SolrQuery();
         solrQuery.add(solrParams);
         List<FacetResult> allFacets = getAllFacetResults(ldProgramName);
-        SolrQueryUtil.setFacetFields(solrQuery, allFacets);
         QueryResponse queryResponse = solrSearch.search(solrQuery, 
ldProgramName);
         String queryTerm = 
SolrQueryUtil.extractQueryTermFromSolrQuery(solrParams);
         return search(queryTerm, queryResponse, ontologyURI, ldProgramName, 
allFacets);

Modified: 
stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java
URL: 
http://svn.apache.org/viewvc/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java?rev=1450090&r1=1450089&r2=1450090&view=diff
==============================================================================
--- 
stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java
 (original)
+++ 
stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java
 Tue Feb 26 09:18:53 2013
@@ -46,6 +46,8 @@ import org.apache.clerezza.rdf.core.UriR
 import org.apache.clerezza.rdf.core.access.TcManager;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.servlet.SolrRequestParsers;
 import org.apache.stanbol.commons.viewable.Viewable;
 import org.apache.stanbol.commons.web.base.ContextHelper;
 import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
@@ -213,7 +215,8 @@ public class FeaturedSearchResource exte
                                           MediaType acceptedMediaType) throws 
SearchException {
 
         if (solrQuery != null) {
-            this.searchResults = featuredSearch.search(new 
SolrQuery(solrQuery), ontologyURI, indexName);
+            SolrParams solrParams = 
SolrRequestParsers.parseQueryString(solrQuery);
+            this.searchResults = featuredSearch.search(solrParams, 
ontologyURI, indexName);
         } else if (queryTerm != null) {
             Map<String,List<Object>> constraintsMap = 
JSONUtils.convertToMap(jsonCons);
             this.chosenFacets = JSONUtils.convertToString(constraintsMap);


Reply via email to