You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by su...@apache.org on 2012/07/30 14:03:29 UTC

svn commit: r1367062 - in /incubator/stanbol/branches/contenthub-two-layered-structure/contenthub: search/featured/ search/featured/src/license/ search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/ search/featured/src/main/java/...

Author: suat
Date: Mon Jul 30 12:03:28 2012
New Revision: 1367062

URL: http://svn.apache.org/viewvc?rev=1367062&view=rev
Log:
STANBOL-471:
-Merging the changes done for the search modules of Contenthub from the trunk to this branch.
-Changes includes the wrapper over the faceted search functionality of Solr, removal of related keyword search service using the WordNet and some small bug fixes

Added:
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/ConstraintImpl.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/DefaultConstrainedDocumentSet.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FacetImpl.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/ConstrainedDocumentSet.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/Constraint.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/Facet.java
Removed:
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/util/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/appended-resources/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/wordnet/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/resources/
Modified:
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/pom.xml
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/license/THIRD-PARTY.properties
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/pom.xml
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/license/THIRD-PARTY.properties
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchManagerImpl.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchResult.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/referencedsite/ReferencedSiteSearch.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/pom.xml
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/src/license/THIRD-PARTY.properties
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/src/main/java/org/apache/stanbol/contenthub/search/solr/util/SolrQueryUtil.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/FacetResult.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/FeaturedSearch.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/related/RelatedKeywordSearchManager.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/solr/SolrSearch.java

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/pom.xml?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/pom.xml (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/pom.xml Mon Jul 30 12:03:28 2012
@@ -24,7 +24,7 @@
   <artifactId>org.apache.stanbol.contenthub.search.featured</artifactId>
   <packaging>bundle</packaging>
 
-  <name>Apache Stanbol Featured Search</name>
+  <name>Apache Stanbol Contenthub Featured Search</name>
 
   <description>Aggregates the results of SolrSearch and RelatedKeywordSearch</description>
   <build>

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/license/THIRD-PARTY.properties
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/license/THIRD-PARTY.properties?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/license/THIRD-PARTY.properties (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/license/THIRD-PARTY.properties Mon Jul 30 12:03:28 2012
@@ -1,33 +1,30 @@
 # Generated by org.codehaus.mojo.license.AddThirdPartyMojo
 #-------------------------------------------------------------------------------
 # Already used licenses in project :
-# - Apache Software License
-# - Apache Software License, Version 2.0
-# - BSD License
-# - BSD-style
-# - Common Development And Distribution License (CDDL), Version 1.0
-# - Common Development And Distribution License (CDDL), Version 1.1
-# - Common Public License, Version 1.0
-# - Eclipse Public License, Version 1.0
-# - GNU General Public License (GPL), Version 2 with classpath exception
-# - GNU Lesser General Public License (LGPL)
-# - GNU Lesser General Public License (LGPL), Version 2.1
+# - Apache 2
+# - Apache License
+# - Apache Software License, Version 1.1
+# - BSD
+# - BSD-style license
+# - CDDL 1.1
+# - Common Development and Distribution License (CDDL) v1.0
+# - Common Public License Version 1.0
+# - GPL2 w/ CPE
 # - ICU License
 # - MIT License
-# - Public Domain License
-# - Similar to Apache License but with the acknowledgment clause removed
+# - The Apache Software License, Version 2.0
 #-------------------------------------------------------------------------------
 # Please fill the missing licenses for dependencies :
 #
 #
-#Fri Jul 20 09:15:13 EEST 2012
+#Wed Feb 15 19:03:22 CET 2012
 antlr--antlr--2.7.2=Public Domain
 asm--asm--3.1=BSD License
 commons-beanutils--commons-beanutils--1.7.0=The Apache Software License, Version 2.0
 dom4j--dom4j--1.1=BSD-style
 jakarta-regexp--jakarta-regexp--1.4=The Apache Software License, Version 2.0
 javax.portlet--portlet-api--2.0=The Apache Software License, Version 2.0
-javax.servlet--servlet-api--2.5=Common Development And Distribution License (CDDL), Version 1.0
+javax.servlet--servlet-api--2.4=Common Development And Distribution License (CDDL), Version 1.0
 org.apache.zookeeper--zookeeper--3.3.1=The Apache Software License, Version 2.0
 org.codehaus.jettison--jettison--1.3=The Apache Software License, Version 2.0
 org.osgi--org.osgi.compendium--4.1.0=The Apache Software License, Version 2.0

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/ConstraintImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/ConstraintImpl.java?rev=1367062&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/ConstraintImpl.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/ConstraintImpl.java Mon Jul 30 12:03:28 2012
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2012 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.contenthub.search.featured;
+
+import org.apache.stanbol.contenthub.servicesapi.index.search.featured.Constraint;
+import org.apache.stanbol.contenthub.servicesapi.index.search.featured.Facet;
+
+public class ConstraintImpl implements Constraint {
+
+    private String value;
+    private Facet facet;
+
+    public ConstraintImpl(String value, Facet facet) {
+        if (value == null || value.equals("")) {
+            throw new IllegalArgumentException("A non-empty value must be specified");
+        }
+        if (facet == null) {
+            throw new IllegalArgumentException("A non-null facet must be specified");
+        }
+        this.value = value;
+        this.facet = facet;
+        facet.getConstraints().add(this);
+    }
+
+    @Override
+    public Facet getFacet() {
+        return this.facet;
+    }
+
+    @Override
+    public String getValue() {
+        return this.value;
+    }
+
+    @Override
+    public int hashCode() {
+        return value.hashCode() + facet.getLabel(null).hashCode();
+    }
+
+    /**
+     * If the value of two {@link Constraint}s and default labels of their associated facets are equal,
+     * constraints are treated as equal.
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (obj instanceof Constraint) {
+            Constraint c = (Constraint) obj;
+            if (c.getValue().equals(this.getValue()) && c.getFacet().equals(this.getFacet())) {
+                return true;
+            } else {
+                return false;
+            }
+        } else {
+            return false;
+        }
+    }
+}

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/DefaultConstrainedDocumentSet.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/DefaultConstrainedDocumentSet.java?rev=1367062&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/DefaultConstrainedDocumentSet.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/DefaultConstrainedDocumentSet.java Mon Jul 30 12:03:28 2012
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2012 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.contenthub.search.featured;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.clerezza.rdf.core.PlainLiteral;
+import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
+import org.apache.solr.client.solrj.response.FacetField;
+import org.apache.solr.client.solrj.response.FacetField.Count;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrDocumentList;
+import org.apache.stanbol.contenthub.servicesapi.index.search.SearchException;
+import org.apache.stanbol.contenthub.servicesapi.index.search.featured.ConstrainedDocumentSet;
+import org.apache.stanbol.contenthub.servicesapi.index.search.featured.Constraint;
+import org.apache.stanbol.contenthub.servicesapi.index.search.featured.Facet;
+import org.apache.stanbol.contenthub.servicesapi.index.search.featured.FeaturedSearch;
+import org.apache.stanbol.contenthub.servicesapi.store.vocabulary.SolrVocabulary.SolrFieldName;
+
+/**
+ * This implementation of {@link ConstrainedDocumentSet} retrieves all results without any smart retrieval
+ * technique e.g retrieve actual documents from the storage when the respective documents are accessed.
+ * 
+ * @author suat
+ * 
+ */
+public class DefaultConstrainedDocumentSet implements ConstrainedDocumentSet {
+
+    private String queryTerm;
+    private FeaturedSearch featuredSearch;
+    private String indexName;
+    private List<String> documentURIs;
+    private Set<Constraint> constraints;
+    private Set<Facet> facets;
+
+    public DefaultConstrainedDocumentSet(String queryTerm,
+                                         QueryResponse queryResponse,
+                                         Set<Constraint> constraints,
+                                         String indexName,
+                                         FeaturedSearch featuredSearch) throws SearchException {
+        this.queryTerm = queryTerm;
+        this.indexName = indexName;
+        this.featuredSearch = featuredSearch;
+        this.constraints = constraints;
+        parseQueryResponse(queryResponse);
+    }
+
+    @Override
+    public List<String> getDocuments() throws SearchException {
+        return documentURIs;
+    }
+
+    private void parseQueryResponse(QueryResponse queryResponse) {
+        // parse ids
+        List<String> ids = new ArrayList<String>();
+        SolrDocumentList documentList = queryResponse.getResults();
+        for (SolrDocument solrDocument : documentList) {
+            Object uri = solrDocument.getFieldValue(SolrFieldName.ID.toString());
+            if (uri != null) {
+                ids.add(uri.toString());
+            }
+        }
+        documentURIs = ids;
+
+        // parse facets
+        Set<Facet> facets = new HashSet<Facet>();
+        for (FacetField facetField : queryResponse.getFacetFields()) {
+            List<PlainLiteral> labels = new ArrayList<PlainLiteral>();
+            labels.add(new PlainLiteralImpl(facetField.getName()));
+            Facet facet = new FacetImpl(labels);
+            facets.add(facet);
+            List<Count> values = facetField.getValues();
+            if (values != null) {
+                for (Count count : facetField.getValues()) {
+                    new ConstraintImpl(count.getName(), facet);
+                }
+            }
+        }
+        this.facets = facets;
+    }
+
+    @Override
+    public Set<Constraint> getConstraints() {
+        return this.constraints != null ? this.constraints : new HashSet<Constraint>();
+    }
+
+    @Override
+    public Set<Facet> getFacets() {
+        return this.facets;
+    }
+
+    @Override
+    public ConstrainedDocumentSet narrow(Constraint constraint) throws SearchException {
+        Set<Constraint> newConstraints = new HashSet<Constraint>(getConstraints());
+        newConstraints.add(constraint);
+        return featuredSearch.search(queryTerm, newConstraints, indexName);
+    }
+
+    @Override
+    public ConstrainedDocumentSet broaden(Constraint constraint) throws SearchException {
+        Set<Constraint> newConstraints = new HashSet<Constraint>(getConstraints());
+        newConstraints.remove(constraint);
+        return featuredSearch.search(queryTerm, newConstraints, indexName);
+    }
+}

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FacetImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FacetImpl.java?rev=1367062&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FacetImpl.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FacetImpl.java Mon Jul 30 12:03:28 2012
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2012 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.contenthub.search.featured;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import org.apache.clerezza.rdf.core.PlainLiteral;
+import org.apache.stanbol.contenthub.servicesapi.index.search.featured.Constraint;
+import org.apache.stanbol.contenthub.servicesapi.index.search.featured.Facet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FacetImpl implements Facet {
+    private static final Logger log = LoggerFactory.getLogger(FacetImpl.class);
+
+    private Set<Constraint> constraints;
+
+    private List<PlainLiteral> labels;
+
+    /**
+     * Creates a {@link Facet} with given <code>constraints</code> and <code>labels</code>. The first item of
+     * label list is considered as the default label of the this facet. The default label of a facet is
+     * obtained by <code>getLabel(null)</code>.It is important, because any facets are considered as equal if
+     * their default labels are the same.
+     * 
+     * @param constraints
+     *            all possible {@link Constraint} corresponding to the facet values
+     * @param labels
+     *            a list of labels representing this facet. First of the labels passed in this list is
+     *            considered as the default value of this facet
+     */
+    public FacetImpl(List<PlainLiteral> labels) {
+        if (labels == null || labels.isEmpty()) {
+            throw new IllegalArgumentException("Label list must include at least one item");
+        }
+        this.labels = labels;
+        this.constraints = new HashSet<Constraint>();
+    }
+
+    @Override
+    public Set<Constraint> getConstraints() {
+        return this.constraints;
+    }
+
+    @Override
+    public String getLabel(Locale locale) {
+        if (locale == null) {
+            return labels.get(0).getLexicalForm();
+        } else {
+            for (PlainLiteral pl : labels) {
+                if (pl.getLanguage().toString().equals(locale.getLanguage())) {
+                    return pl.getLexicalForm();
+                }
+            }
+            log.warn("There is no label for specified language: {}. Returnin default label ",
+                locale.getLanguage());
+            return labels.get(0).getLexicalForm();
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        return labels.get(0).getLexicalForm().hashCode();
+    }
+
+    /**
+     * If the default labels of two {@link Facet}s are equal, they are considered as equal. Default label of a
+     * facet is obtained by passing a <code>null</code> parameter to {@link #getLabel(Locale)} method.
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (obj instanceof Facet) {
+            return this.getLabel(null).equals(((Facet) obj).getLabel(null));
+        } else {
+            return false;
+        }
+    }
+}

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java Mon Jul 30 12:03:28 2012
@@ -44,8 +44,9 @@ import org.apache.stanbol.commons.semant
 import org.apache.stanbol.commons.semanticindex.index.SemanticIndexManager;
 import org.apache.stanbol.contenthub.index.ldpath.LDPathSemanticIndex;
 import org.apache.stanbol.contenthub.search.solr.util.SolrQueryUtil;
-import org.apache.stanbol.contenthub.servicesapi.Constants;
 import org.apache.stanbol.contenthub.servicesapi.index.search.SearchException;
+import org.apache.stanbol.contenthub.servicesapi.index.search.featured.ConstrainedDocumentSet;
+import org.apache.stanbol.contenthub.servicesapi.index.search.featured.Constraint;
 import org.apache.stanbol.contenthub.servicesapi.index.search.featured.FacetResult;
 import org.apache.stanbol.contenthub.servicesapi.index.search.featured.FeaturedSearch;
 import org.apache.stanbol.contenthub.servicesapi.index.search.featured.SearchResult;
@@ -57,7 +58,7 @@ import org.apache.stanbol.enhancer.servi
 import org.apache.stanbol.enhancer.servicesapi.ContentItemFactory;
 import org.apache.stanbol.enhancer.servicesapi.EnhancementException;
 import org.apache.stanbol.enhancer.servicesapi.EnhancementJobManager;
-import org.apache.stanbol.enhancer.servicesapi.impl.ByteArraySource;
+import org.apache.stanbol.enhancer.servicesapi.impl.StringSource;
 import org.apache.stanbol.enhancer.servicesapi.rdf.Properties;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -108,13 +109,6 @@ public class FeaturedSearchImpl implemen
     @Reference
     private ContentItemFactory contentItemFactory;
 
-    // private BundleContext bundleContext;
-    //
-    // @Activate
-    // public void activate(ComponentContext context) {
-    // this.bundleContext = context.getBundleContext();
-    // }
-
     private List<FacetResult> convertFacetFields(List<FacetField> facetFields, List<FacetResult> allFacets) {
         List<FacetResult> facets = new ArrayList<FacetResult>();
         if (allFacets == null) {
@@ -168,19 +162,33 @@ public class FeaturedSearchImpl implemen
 
     @Override
     public SearchResult search(SolrParams solrParams, String ontologyURI, String indexName) throws SearchException {
-        /*
-         * RESTful services uses search method with "SolrParams" argument. For those operations
-         */
         SolrQuery solrQuery = new SolrQuery();
         solrQuery.add(solrParams);
         List<FacetResult> allFacets = getAllFacetResults(indexName);
-        SolrQueryUtil.setDefaultQueryParameters(solrQuery, allFacets);
+        SolrQueryUtil.setFacetFields(solrQuery, allFacets);
         QueryResponse queryResponse = solrSearch.search(solrQuery, indexName);
         String queryTerm = SolrQueryUtil.extractQueryTermFromSolrQuery(solrParams);
         return search(queryTerm, queryResponse, ontologyURI, indexName, allFacets);
     }
 
     @Override
+    public ConstrainedDocumentSet search(String keyword, Set<Constraint> constraints, String indexName) throws SearchException {
+        return performSearch(keyword, constraints, indexName);
+    }
+
+    private ConstrainedDocumentSet performSearch(String keyword, Set<Constraint> constraints, String indexName) throws SearchException {
+        SolrQuery query = SolrQueryUtil.prepareSolrQuery(keyword);
+        SolrQueryUtil.addConstraintsToSolrQuery(constraints, query);
+        List<FacetResult> allFacets = getAllFacetResults(indexName);
+        SolrQueryUtil.setFacetFields(query, allFacets);
+        query.setRows(Integer.MAX_VALUE);
+        query.setFields(SolrFieldName.ID.toString(), SolrFieldName.ENHANCEMENTCOUNT.toString(),
+            SolrFieldName.TITLE.toString(), SolrFieldName.MIMETYPE.toString());
+        QueryResponse queryResponse = solrSearch.search(query, indexName);
+        return new DefaultConstrainedDocumentSet(keyword, queryResponse, constraints, indexName, this);
+    }
+
+    @Override
     public List<FacetResult> getAllFacetResults(String indexName) throws SearchException {
         LDPathSemanticIndex semanticIndex = null;
         try {
@@ -212,8 +220,7 @@ public class FeaturedSearchImpl implemen
         ContentItem ci = null;
         boolean error = false;
         try {
-            ci = contentItemFactory.createContentItem(new ByteArraySource(queryTerm
-                    .getBytes(Constants.DEFAULT_ENCODING), "text/plain"));
+            ci = contentItemFactory.createContentItem(new StringSource(queryTerm));
             enhancementJobManager.enhanceContent(ci);
         } catch (UnsupportedEncodingException e) {
             log.error("Failed to get bytes of query term: {}", queryTerm, e);

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/pom.xml?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/pom.xml (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/pom.xml Mon Jul 30 12:03:28 2012
@@ -24,10 +24,11 @@
   <artifactId>org.apache.stanbol.contenthub.search.related</artifactId>
   <packaging>bundle</packaging>
 
-  <name>Apache Stanbol Search Related Keyword Searcher</name>
+  <name>Apache Stanbol Contenthub Related Keyword Searcher</name>
 
-  <description>Finds ontlogy classes and individuals based on query keywords
-Finds related keywords from various types of source e.g Wordnet, an external ontology, semantic information obtained through referenced sites
+  <description>Finds related keywords for the original query term from various sources which are
+    any external ontology and referenced sites managed by Stanbol. However, currently only DBPEDIA
+    is used. 
   </description>
   <build>
     <plugins>
@@ -35,12 +36,6 @@ Finds related keywords from various type
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
         <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Embed-Dependency>jaws</Embed-Dependency>
-            <Export-Package>edu.smu.tspell.*</Export-Package>
-          </instructions>
-        </configuration>
       </plugin>
       <plugin>
         <groupId>org.apache.felix</groupId>
@@ -56,6 +51,11 @@ Finds related keywords from various type
     </dependency>
     <dependency>
       <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.entityhub.servicesapi</artifactId>
+      <version>0.11.0-incubating-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.stanbol</groupId>
       <artifactId>org.apache.stanbol.contenthub.servicesapi</artifactId>
       <version>0.10.0-incubating-SNAPSHOT</version>
     </dependency>
@@ -88,25 +88,5 @@ Finds related keywords from various type
       <groupId>com.hp.hpl.jena</groupId>
       <artifactId>arq</artifactId>
     </dependency>
-
-    <!-- Jaws Wordnet client -->
-    <dependency>
-      <groupId>edu.smu.tspell</groupId>
-      <artifactId>jaws</artifactId>
-      <version>1.2</version>
-    </dependency>
   </dependencies>
-
-  <repositories>
-    <repository>
-      <releases>
-        <updatePolicy>always</updatePolicy>
-      </releases>
-      <snapshots>
-        <updatePolicy>always</updatePolicy>
-      </snapshots>
-      <id>local-wordnet-repo</id>
-      <url>file://localhost/${project.basedir}/src/main/resources/local-maven-repository</url>
-    </repository>
-  </repositories>
 </project>

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/license/THIRD-PARTY.properties
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/license/THIRD-PARTY.properties?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/license/THIRD-PARTY.properties (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/license/THIRD-PARTY.properties Mon Jul 30 12:03:28 2012
@@ -12,7 +12,6 @@
 # - GNU Lesser General Public License (LGPL)
 # - GNU Lesser General Public License (LGPL), Version 2.1
 # - ICU License
-# - JAWS License
 # - MIT License
 # - Public Domain License
 # - Similar to Apache License but with the acknowledgment clause removed
@@ -20,9 +19,8 @@
 # Please fill the missing licenses for dependencies :
 #
 #
-#Fri Jul 20 09:15:19 EEST 2012
-edu.smu.tspell--jaws--1.2=JAWS License
-javax.servlet--servlet-api--2.5=Common Development And Distribution License (CDDL), Version 1.0
+#Tue Apr 17 08:38:23 EEST 2012
+javax.servlet--servlet-api--2.4=Common Development And Distribution License (CDDL), Version 1.0
 org.apache.zookeeper--zookeeper--3.3.1=The Apache Software License, Version 2.0
 org.osgi--org.osgi.compendium--4.1.0=The Apache Software License, Version 2.0
 org.osgi--org.osgi.core--4.1.0=The Apache Software License, Version 2.0

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchManagerImpl.java?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchManagerImpl.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchManagerImpl.java Mon Jul 30 12:03:28 2012
@@ -29,7 +29,6 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Service;
 import org.apache.stanbol.contenthub.search.related.ontologyresource.OntologyResourceSearch;
 import org.apache.stanbol.contenthub.search.related.referencedsite.ReferencedSiteSearch;
-import org.apache.stanbol.contenthub.search.related.wordnet.WordnetSearch;
 import org.apache.stanbol.contenthub.servicesapi.index.search.SearchException;
 import org.apache.stanbol.contenthub.servicesapi.index.search.featured.SearchResult;
 import org.apache.stanbol.contenthub.servicesapi.index.search.related.RelatedKeyword;
@@ -83,11 +82,6 @@ public class RelatedKeywordSearchManager
         relatedKeywordsMap.put(keyword, relatedKeywords);
         return new RelatedKeywordSearchResult(relatedKeywordsMap);
     }
-    
-    @Override
-    public SearchResult getRelatedKeywordsFromWordnet(String keyword) throws SearchException {
-        return getRelatedKeywordsFrom(keyword, WordnetSearch.class);
-    }
 
     @Override
     public SearchResult getRelatedKeywordsFromOntology(String keyword, String ontologyURI) throws SearchException {

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchResult.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchResult.java?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchResult.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchResult.java Mon Jul 30 12:03:28 2012
@@ -58,16 +58,16 @@ public class RelatedKeywordSearchResult 
 
     @Override
     public void setDocuments(List<String> resultantDocuments) {
-        // String msg = "RelatedKeywordSearchResult cannot contain any ResultantDocument";
-        // log.error(msg);
-        // throw new NotImplementedException(msg);
+        String msg = "RelatedKeywordSearchResult cannot contain any ResultantDocument";
+        log.error(msg);
+        throw new UnsupportedOperationException(msg);
     }
 
     @Override
     public void setFacets(List<FacetResult> facets) {
-        // String msg = "RelatedKeywordSearchResult cannot contain any FacetField";
-        // log.error(msg);
-        // throw new NotImplementedException(msg);
+        String msg = "RelatedKeywordSearchResult cannot contain any FacetField";
+        log.error(msg);
+        throw new UnsupportedOperationException(msg);
     }
 
     @Override

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/referencedsite/ReferencedSiteSearch.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/referencedsite/ReferencedSiteSearch.java?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/referencedsite/ReferencedSiteSearch.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/referencedsite/ReferencedSiteSearch.java Mon Jul 30 12:03:28 2012
@@ -45,7 +45,7 @@ import org.apache.stanbol.entityhub.serv
 import org.apache.stanbol.entityhub.servicesapi.query.QueryResultList;
 import org.apache.stanbol.entityhub.servicesapi.query.TextConstraint;
 import org.apache.stanbol.entityhub.servicesapi.query.TextConstraint.PatternType;
-import org.apache.stanbol.entityhub.servicesapi.site.ReferencedSiteManager;
+import org.apache.stanbol.entityhub.servicesapi.site.SiteManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -96,7 +96,7 @@ public class ReferencedSiteSearch implem
     private Entityhub entityhub;
 
     @Reference
-    private ReferencedSiteManager referencedSiteManager;
+    private SiteManager referencedSiteManager;
 
     @Override
     public Map<String,List<RelatedKeyword>> search(String keyword) throws SearchException {

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/pom.xml?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/pom.xml (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/pom.xml Mon Jul 30 12:03:28 2012
@@ -24,9 +24,9 @@
   <artifactId>org.apache.stanbol.contenthub.search.solr</artifactId>
   <packaging>bundle</packaging>
 
-  <name>Apache Stanbol Search Solr Searcher</name>
+  <name>Apache Stanbol Contenthub Solr Search</name>
 
-  <description>Finds indexed document from Solr according to field constraints</description>
+  <description>Provides search over the underlying Solr cores used by Semantic Indexes</description>
   <build>
     <plugins>
       <plugin>

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/src/license/THIRD-PARTY.properties
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/src/license/THIRD-PARTY.properties?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/src/license/THIRD-PARTY.properties (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/src/license/THIRD-PARTY.properties Mon Jul 30 12:03:28 2012
@@ -1,33 +1,30 @@
 # Generated by org.codehaus.mojo.license.AddThirdPartyMojo
 #-------------------------------------------------------------------------------
 # Already used licenses in project :
-# - Apache Software License
-# - Apache Software License, Version 2.0
-# - BSD License
-# - BSD-style
-# - Common Development And Distribution License (CDDL), Version 1.0
-# - Common Development And Distribution License (CDDL), Version 1.1
-# - Common Public License, Version 1.0
-# - Eclipse Public License, Version 1.0
-# - GNU General Public License (GPL), Version 2 with classpath exception
-# - GNU Lesser General Public License (LGPL)
-# - GNU Lesser General Public License (LGPL), Version 2.1
+# - Apache 2
+# - Apache License
+# - Apache Software License, Version 1.1
+# - BSD
+# - BSD-style license
+# - CDDL 1.1
+# - Common Development and Distribution License (CDDL) v1.0
+# - Common Public License Version 1.0
+# - GPL2 w/ CPE
 # - ICU License
 # - MIT License
-# - Public Domain License
-# - Similar to Apache License but with the acknowledgment clause removed
+# - The Apache Software License, Version 2.0
 #-------------------------------------------------------------------------------
 # Please fill the missing licenses for dependencies :
 #
 #
-#Fri Jul 20 09:15:09 EEST 2012
+#Wed Feb 15 19:03:04 CET 2012
 antlr--antlr--2.7.2=Public Domain
 asm--asm--3.1=BSD License
 commons-beanutils--commons-beanutils--1.7.0=The Apache Software License, Version 2.0
 dom4j--dom4j--1.1=BSD-style
 jakarta-regexp--jakarta-regexp--1.4=The Apache Software License, Version 2.0
 javax.portlet--portlet-api--2.0=The Apache Software License, Version 2.0
-javax.servlet--servlet-api--2.5=Common Development And Distribution License (CDDL), Version 1.0
+javax.servlet--servlet-api--2.4=Common Development And Distribution License (CDDL), Version 1.0
 org.apache.zookeeper--zookeeper--3.3.1=The Apache Software License, Version 2.0
 org.codehaus.jettison--jettison--1.3=The Apache Software License, Version 2.0
 org.osgi--org.osgi.compendium--4.1.0=The Apache Software License, Version 2.0

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/src/main/java/org/apache/stanbol/contenthub/search/solr/util/SolrQueryUtil.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/src/main/java/org/apache/stanbol/contenthub/search/solr/util/SolrQueryUtil.java?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/src/main/java/org/apache/stanbol/contenthub/search/solr/util/SolrQueryUtil.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/search/solr/src/main/java/org/apache/stanbol/contenthub/search/solr/util/SolrQueryUtil.java Mon Jul 30 12:03:28 2012
@@ -22,6 +22,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServer;
@@ -31,6 +32,8 @@ import org.apache.solr.client.solrj.util
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
+import org.apache.stanbol.contenthub.servicesapi.index.search.featured.Constraint;
+import org.apache.stanbol.contenthub.servicesapi.index.search.featured.Facet;
 import org.apache.stanbol.contenthub.servicesapi.index.search.featured.FacetResult;
 import org.apache.stanbol.contenthub.servicesapi.store.vocabulary.SolrVocabulary;
 import org.apache.stanbol.contenthub.servicesapi.store.vocabulary.SolrVocabulary.SolrFieldName;
@@ -57,41 +60,6 @@ public class SolrQueryUtil {
 
     public final static List<Character> queryDelimiters = Arrays.asList(' ', ',');
 
-    private static String getFacetFieldType(String fieldName, List<FacetResult> allAvailableFacets) {
-        for (FacetResult fr : allAvailableFacets) {
-            if (fieldName.equals(fr.getFacetField().getName())) {
-                return fr.getType();
-            }
-        }
-        return "";
-    }
-
-    private static SolrQuery keywordQueryWithFacets(String keyword,
-                                                    List<FacetResult> allAvailableFacets,
-                                                    Map<String,List<Object>> constraints) {
-        SolrQuery query = new SolrQuery();
-        query.setQuery(keyword);
-        if (constraints != null) {
-            try {
-                for (Entry<String,List<Object>> entry : constraints.entrySet()) {
-                    String fieldName = ClientUtils.escapeQueryChars(entry.getKey());
-                    String type = getFacetFieldType(fieldName, allAvailableFacets);
-                    for (Object value : entry.getValue()) {
-                        if (SolrVocabulary.isRangeType(type)) {
-                            query.addFilterQuery(fieldName + facetDelimiter + (String) value);
-                        } else {
-                            query.addFilterQuery(fieldName + facetDelimiter + quotation
-                                                 + ClientUtils.escapeQueryChars((String) value) + quotation);
-                        }
-                    }
-                }
-            } catch (Exception e) {
-                log.warn("Facet constraints could not be added to Query", e);
-            }
-        }
-        return query;
-    }
-
     private static String removeFacetConstraints(String query) {
         int delimiteri = query.indexOf(facetDelimiter);
         while (delimiteri > -1) {
@@ -146,7 +114,18 @@ public class SolrQueryUtil {
         return queryFull.trim();
     }
 
-    public static <T> void setDefaultQueryParameters(SolrQuery solrQuery, List<T> allAvailableFacetNames) {
+    /**
+     * This methods adds a facet field the given <code>solrQuery</code> for each facet passed in
+     * <code>allAvailableFacetNames</code>. This provides obtaining information about specified facets such as
+     * possible facet values, number documents of documents matching with certain values of facets, etc in the
+     * search results.
+     * 
+     * @param solrQuery
+     *            {@link SolrQuery} to be extended with facet fields
+     * @param allAvailableFacetNames
+     *            list of facets
+     */
+    public static <T> void setFacetFields(SolrQuery solrQuery, List<T> allAvailableFacetNames) {
         solrQuery.setFields("*", SCORE_FIELD);
         solrQuery.setFacet(true);
         solrQuery.setFacetMinCount(1);
@@ -160,32 +139,96 @@ public class SolrQueryUtil {
                 } else {
                     facetName = facet.toString();
                 }
-                if (!SolrFieldName.isNameReserved(facetName) && !SolrVocabulary.isNameExcluded(facetName)) {
+                if (SolrFieldName.CREATIONDATE.toString().equals(facetName)
+                    || (!SolrFieldName.isNameReserved(facetName) && !SolrVocabulary.isNameExcluded(facetName))) {
                     solrQuery.addFacetField(facetName);
                 }
             }
         }
     }
 
+    /**
+     * This method create a {@link SolrQuery} using the given parameters. <code>queryTerm</code> is the main
+     * query of the solr query to be created. <code>solrServer</code> is used fetch possible facet fields of
+     * the underlying Solr schema. Obtained facet names are attached to the query to obtain the corresponding
+     * facet information such as possible facet values, number documents of documents matching with certain
+     * values of facets, etc in the search results.
+     * 
+     * @param solrServer
+     *            Solr server to obtain corresponding facet names
+     * @param queryTerm
+     *            main query term to be used in {@link SolrQuery#setQuery(String)}
+     * @return {@link SolrQuery} constructed by using the given parameters
+     * @throws SolrServerException
+     * @throws IOException
+     */
     public static SolrQuery prepareSolrQuery(SolrServer solrServer, String queryTerm) throws SolrServerException,
                                                                                      IOException {
         SolrQuery solrQuery = new SolrQuery();
         solrQuery.setQuery(queryTerm);
-        setDefaultQueryParameters(solrQuery, getAllFacetNames(solrServer));
+        setFacetFields(solrQuery, getAllFacetNames(solrServer));
         return solrQuery;
     }
 
+    /**
+     * This method simply wraps the given <code>queryTerm</code> in a {@link SolrQuery} instance.
+     * 
+     * @param queryTerm
+     *            {@link String} query term to be represented as a {@link SolrQuery}
+     * @return {@link SolrQuery} wrapping the given <code>queryTerm</code>
+     */
     public static SolrQuery prepareSolrQuery(String queryTerm) {
         SolrQuery solrQuery = new SolrQuery();
         solrQuery.setQuery(queryTerm);
         return solrQuery;
     }
 
+    /**
+     * This method creates a {@link SolrQuery} with the given parameters. It sets the <code>queryTerm</code>
+     * as the main query and for each constraint passed in the <code>constraints</code> a filter query is
+     * added to the solr query.
+     * 
+     * @param queryTerm
+     *            main query to be used in {@link SolrQuery#setQuery(String)}
+     * @param allAvailableFacets
+     *            {@link FacetResult}s passed in this list are used to check types of the facets.
+     * @param constraints
+     *            additional constraints to be applied in the {@link SolrQuery}.
+     * @return {@link SolrQuery} constructed by using the given parameters
+     */
     public static SolrQuery prepareSolrQuery(String queryTerm,
                                              List<FacetResult> allAvailableFacets,
                                              Map<String,List<Object>> constraints) {
-        SolrQuery solrQuery = keywordQueryWithFacets(queryTerm, allAvailableFacets, constraints);
-        return solrQuery;
+        SolrQuery query = new SolrQuery();
+        query.setQuery(queryTerm);
+        if (constraints != null) {
+            try {
+                for (Entry<String,List<Object>> entry : constraints.entrySet()) {
+                    String fieldName = ClientUtils.escapeQueryChars(entry.getKey());
+                    String type = getFacetFieldType(fieldName, allAvailableFacets);
+                    for (Object value : entry.getValue()) {
+                        if (SolrVocabulary.isRangeType(type)) {
+                            query.addFilterQuery(fieldName + facetDelimiter + (String) value);
+                        } else {
+                            query.addFilterQuery(fieldName + facetDelimiter + quotation
+                                                 + ClientUtils.escapeQueryChars((String) value) + quotation);
+                        }
+                    }
+                }
+            } catch (Exception e) {
+                log.warn("Facet constraints could not be added to Query", e);
+            }
+        }
+        return query;
+    }
+
+    private static String getFacetFieldType(String fieldName, List<FacetResult> allAvailableFacets) {
+        for (FacetResult fr : allAvailableFacets) {
+            if (fieldName.equals(fr.getFacetField().getName())) {
+                return fr.getType();
+            }
+        }
+        return "";
     }
 
     public static List<String> getAllFacetNames(SolrServer solrServer) throws SolrServerException,
@@ -212,4 +255,22 @@ public class SolrQueryUtil {
                     "Fields container is not a NamedList, so there is no facet information available");
         }
     }
+
+    /**
+     * This method parses the {@link Set} of {@link Constraint} and update the {@link SolrQuery} with
+     * corresponding field queries. Name of the field is obtained from associated {@link Facet} of a
+     * constraint and the value is obtained from the constraint itself.
+     * 
+     * @param constraints
+     *            {@link Set} of {@link Constraint}s to be transformed into the given <code>solrQuery</code>
+     * @param solrQuery
+     *            {@link SolrQuery} to be updated with the given <code>constraints</code>
+     */
+    public static void addConstraintsToSolrQuery(Set<Constraint> constraints, SolrQuery solrQuery) {
+        if (constraints != null) {
+            for (Constraint constraint : constraints) {
+                solrQuery.addFilterQuery(constraint.getFacet().getLabel(null) + ":" + constraint.getValue());
+            }
+        }
+    }
 }

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/ConstrainedDocumentSet.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/ConstrainedDocumentSet.java?rev=1367062&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/ConstrainedDocumentSet.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/ConstrainedDocumentSet.java Mon Jul 30 12:03:28 2012
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2012 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.contenthub.servicesapi.index.search.featured;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.stanbol.contenthub.servicesapi.index.search.SearchException;
+
+/**
+ * A set of documents that can be narrowed by applying {@link Constraint}s that are grouped by {@link Facet}s.
+ * Instances of this class are immutable, narrowing and broadening return new instances.
+ */
+public interface ConstrainedDocumentSet {
+    /**
+     * Returns the documents contained in this {@link ConstrainedDocumentSet}. There is no defined order of
+     * the list, but implementations should keep the order stable as too allow stateless pagination.
+     * 
+     * Implementations may populate the list just when the respective elements are accessed and implement
+     * size() to access optimized backend functionality. Clients must thus take into account the possibility
+     * that the list changes while they are using it. For example the size returned by List.size() may not
+     * match the actual number of elements when iterating throw it at a later point in time. The iterate() as
+     * well as the subList(int,int) method are safe.
+     * 
+     * @return the documents included in this {@link ConstrainedDocumentSet}
+     * @throws SearchException
+     */
+    List<String> getDocuments() throws SearchException;
+
+    /**
+     * This method returns the {@link Set} of {@link Constraint}s which have been used to obtain the documents
+     * included in this set.
+     * 
+     * @return the constrains that apply to this ConstrainedDocumentSet (might be empty)
+     */
+    Set<Constraint> getConstraints();
+
+    /**
+     * This method returns all possible {@link Facet}s together with all their possible {@link Constraint}s
+     * that can be used to filter documents included in this set.
+     * 
+     * @return the {@link Facet}s by which this {@link ConstrainedDocumentSet} can be restricted.
+     */
+    Set<Facet> getFacets();
+
+    /**
+     * Note that the new set need not to be computed when this method is called, the matching document might
+     * be computed when needed. So implimentations can provided efficient way to allow a client to call
+     * 
+     * <code>narrow(additionalConstraint).getDocuments().size()</code>
+     * 
+     * Creates a new {@link ConstrainedDocumentSet} with the new set of {@link Constraint} which is formed by
+     * adding the specified <code>constraint</code> the constraint set returned by {@link #getConstraints()}.
+     * 
+     * @param constraint
+     *            the additional {@link Constraint} to apply
+     * @return the restricted {@link ConstrainedDocumentSet} by applying the given additional
+     *         <code>constraint</code>
+     * @throws SearchException
+     */
+    ConstrainedDocumentSet narrow(Constraint constraint) throws SearchException;
+
+    /**
+     * Creates a new {@link ConstrainedDocumentSet} with the new set of {@link Constraint}s which is formed by
+     * removing the specified <code>constraint</code> from the constraint set returned by
+     * {@link #getConstraints()}.
+     * 
+     * @param constraint
+     *            the {@link Constraint} which must be member of the set returned by {@link #getConstraints()}
+     * @return the broadened {@link ConstrainedDocumentSet} by removing the given <code>constraint</code>.
+     * @throws SearchException
+     */
+    ConstrainedDocumentSet broaden(Constraint constraint) throws SearchException;
+
+}

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/Constraint.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/Constraint.java?rev=1367062&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/Constraint.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/Constraint.java Mon Jul 30 12:03:28 2012
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2012 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.contenthub.servicesapi.index.search.featured;
+
+import org.apache.clerezza.rdf.core.Resource;
+
+/**
+ * {@link Constraint} is used while doing a search using {@link FeaturedSearch} of Contenthub. It provides
+ * specifying additional restrictions other than the original query keyword for the search operation. A
+ * constraint requires a document property to have a certain value. A document property corresponds to a
+ * {@link Facet} and constraints are parts of facets. A constraint represents one of the possible values of a
+ * facet.
+ * 
+ * <p>
+ * For example, assume a document has a property <b>places</b> indicating the related places with the
+ * document. This property corresponds to a facet and assume that this facet has two values <b>Paris</b> and
+ * <b>London</b>. Each such value of a facet is represented with a separate constraint.
+ * </p>
+ */
+public interface Constraint {
+    /**
+     * @return the {@link Facet} this constraint relates to.
+     */
+    Facet getFacet();
+
+    /**
+     * This method returns the value of this {@link Constraint}. Documents matching this constraint have the
+     * value to be returned as value of one of their properties. That certain document property corresponds to
+     * the {@link Facet} which is associated with this constraint.
+     * 
+     * @return the value of this constraint as a {@link Resource}.
+     */
+    String getValue();
+}

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/Facet.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/Facet.java?rev=1367062&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/Facet.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/Facet.java Mon Jul 30 12:03:28 2012
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2012 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.contenthub.servicesapi.index.search.featured;
+
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * A {@link Facet} is an aspect by which the {@link ConstrainedDocumentSet} can be narrowed. Facets correspond
+ * to properties of documents and they are used in the search operations in {@link FeaturedSearch} of
+ * Contenthub. Facets are considered as equal if their default labels are the same. Default labels of facets
+ * are obtained by providing <code>null</code> to {@link #getLabel(Locale)}.
+ */
+public interface Facet {
+
+    /**
+     * This methods return all possible values regarding this facet wrapped in a {@link Set} of
+     * {@link Constraint}s. Constraints are used to filter search results based on certain values of facets.
+     * 
+     * @return a {@link Set} of constraints that reduce the document to a non-empty set
+     */
+    Set<Constraint> getConstraints();
+
+    /**
+     * Returns a label for this {@link Facet} based on the given {@link Locale} preference.
+     * 
+     * @param locale
+     *            the desired {@link Locale} or <code>null</code> if no preference.
+     * @return a label for this facet
+     */
+    String getLabel(Locale locale);
+
+}
\ No newline at end of file

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/FacetResult.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/FacetResult.java?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/FacetResult.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/FacetResult.java Mon Jul 30 12:03:28 2012
@@ -28,8 +28,8 @@ import org.apache.solr.client.solrj.resp
  */
 public interface FacetResult {
 
-	FacetField getFacetField();
-	
-	String getType();
-	
+    FacetField getFacetField();
+
+    String getType();
+
 }

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/FeaturedSearch.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/FeaturedSearch.java?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/FeaturedSearch.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/featured/FeaturedSearch.java Mon Jul 30 12:03:28 2012
@@ -17,6 +17,7 @@
 package org.apache.stanbol.contenthub.servicesapi.index.search.featured;
 
 import java.util.List;
+import java.util.Set;
 
 import org.apache.solr.common.params.SolrParams;
 import org.apache.stanbol.contenthub.servicesapi.index.search.SearchException;
@@ -52,8 +53,8 @@ public interface FeaturedSearch {
      * @param ontologyURI
      *            URI of an ontology in which related keywords will be searched
      * @param indexName
-     *            Name of the Solr core/index which is used to obtained the corresponding Solr core which will
-     *            be searched for the given query term
+     *            LDPath program name (name of the Solr core/index) which is used to obtained the
+     *            corresponding Solr core which will be searched for the given query term
      * @return {@link SearchResult} for the given query term. For details of the response see
      *         {@link SearchResult}.
      * @throws SearchException
@@ -73,11 +74,6 @@ public interface FeaturedSearch {
      * 
      * @param solrQuery
      *            for which the search results will be obtained
-     * @param ontologyURI
-     *            URI of an ontology in which related keywords will be searched
-     * @param indexName
-     *            Name of the Solr core/index which is used to obtained the corresponding Solr core which will
-     *            be searched for the given solrQuery
      * @return a unified response in a {@link SearchResult} containing actual content items, related keywords
      *         and facets for the obtained content items.
      * @throws SearchException
@@ -85,6 +81,27 @@ public interface FeaturedSearch {
     SearchResult search(SolrParams solrQuery, String ontologyURI, String indexName) throws SearchException;
 
     /**
+     * This method searches the given <code>keyword</code> in the Solr index identified by the given
+     * <code>indexName</code> considering the given <code>constraints</code>. Results are returned in a
+     * {@link ConstrainedDocumentSet} instance and all search results are returned without considering any
+     * <i>offset</i> or <i>limit</i> value. Furthermore, returned {@link ConstrainedDocumentSet} contains
+     * {@link Constraint}s that were used to filter the results and all possible {@link Facet}s that can be
+     * used to filter results even more.
+     * 
+     * @param keyword
+     *            keyword to be searched
+     * @param constraints
+     *            a {@link Set} of {@link Constraint}s to be provided in addition to initial query
+     *            <code>keyword</code>
+     * @param indexName
+     *            name of the index (Solr core) on which search will be done
+     * @return an instance of {@link ConstrainedDocumentSet} including the search results and additional
+     *         {@link Constraint} and {@link Facet} information.
+     * @throws SearchException
+     */
+    ConstrainedDocumentSet search(String keyword, Set<Constraint> constraints, String indexName) throws SearchException;
+
+    /**
      * This method obtains the available field names of the index, corresponding to the given
      * <code>indexName</code> of Contenthub. This name corresponds to a Solr Core name within Contenthub.
      * 
@@ -92,7 +109,6 @@ public interface FeaturedSearch {
      *            Name of the index for which the field names will be obtained.
      * @return {@link List} of field names related index
      * @throws SearchException
-     * @throws IndexManagementException
      */
     List<FacetResult> getAllFacetResults(String indexName) throws SearchException;
 

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/related/RelatedKeywordSearchManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/related/RelatedKeywordSearchManager.java?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/related/RelatedKeywordSearchManager.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/related/RelatedKeywordSearchManager.java Mon Jul 30 12:03:28 2012
@@ -70,20 +70,6 @@ public interface RelatedKeywordSearchMan
     SearchResult getRelatedKeywordsFromAllSources(String keyword, String ontologyURI) throws SearchException;
 
     /**
-     * Searches related keywords in the Wordnet database for the given <code>keyword</code>.
-     * 
-     * @param keyword
-     *            Keyword for which related keywords will be obtained
-     * @return a {@link SearchResult} instance which encapsulates the related keyword {@link Map}. This map
-     *         would have a single key which is the given <code>keyword</code>. The value corresponding to the
-     *         key is another map. It also has a single key which indicates the "Wordnet" source. Value
-     *         corresponding to this key contains {@link List} of {@link RelatedKeyword}s obtained from
-     *         Wordnet.
-     * @throws SearchException
-     */
-    SearchResult getRelatedKeywordsFromWordnet(String keyword) throws SearchException;
-
-    /**
      * Searches related keywords from the ontology specified by <code>ontologyURI</code> for the given
      * <code>keyword</code>.
      * 

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/solr/SolrSearch.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/solr/SolrSearch.java?rev=1367062&r1=1367061&r2=1367062&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/solr/SolrSearch.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/search/solr/SolrSearch.java Mon Jul 30 12:03:28 2012
@@ -38,7 +38,7 @@ public interface SolrSearch {
      * @param queryTerm
      *            Query term to be searched
      * @param indexName
-     *            Index(Solr core) name to obtain the corresponding Solr core to be
+     *            LDPath program name (Solr core/index name) to obtain the corresponding Solr core to be
      *            searched
      * @return the {@link QueryResponse} as is obtained from Solr.
      * @throws SearchException