portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r1094737 - in /portals/jetspeed-2/portal/trunk: applications/jetspeed/src/main/webapp/WEB-INF/solr/js/conf/ components/jetspeed-search/src/main/java/org/apache/jetspeed/search/solr/ components/jetspeed-search/src/test/resources/solr-test-ho...
Date Mon, 18 Apr 2011 20:49:41 GMT
Author: woonsan
Date: Mon Apr 18 20:49:40 2011
New Revision: 1094737

URL: http://svn.apache.org/viewvc?rev=1094737&view=rev
Log:
JS2-1246: Refining Solr based SearchEngine to use searchable fields explicitly.
Also, fixing the default http solr base url with core name for multi-core setup.

Modified:
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/solr/js/conf/schema.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/main/java/org/apache/jetspeed/search/solr/SolrSearchEngineImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/test/resources/solr-test-home/js/conf/schema.xml
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/conf/jetspeed/jetspeed.properties

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/solr/js/conf/schema.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/solr/js/conf/schema.xml?rev=1094737&r1=1094736&r2=1094737&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/solr/js/conf/schema.xml
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/solr/js/conf/schema.xml
Mon Apr 18 20:49:40 2011
@@ -425,7 +425,8 @@
      default: a value that should be used if no value is specified
        when adding a document.
    -->
-
+   
+   <!-- Core Search Fields -->
    <field name="fieldname.key" type="string" indexed="true" stored="true" required="true"
/>
    <field name="fieldname.type" type="text" indexed="true" stored="true" required="false"
/>
    <field name="fieldname.content" type="text" indexed="true" stored="false" required="false"
/>
@@ -438,12 +439,17 @@
    <field name="fieldname.score" type="text" indexed="true" stored="false" required="false"
/>
    <field name="fieldname.className" type="text" indexed="true" stored="true" required="false"
/>
    <field name="fieldname.synthetic" type="text" indexed="true" stored="false" required="false"
/>
-   
+   <!-- Metadata Search Fields -->
    <field name="ID" type="string" indexed="true" stored="true" required="false" />
    <field name="url" type="text" indexed="true" stored="true" required="false" />
    <field name="portlet" type="string" indexed="true" stored="true" required="false" />
    <field name="portlet_application" type="string" indexed="true" stored="true" required="false"
/>
-   
+   <field name="title" type="string" indexed="true" stored="false" multiValued="true"
required="false" />
+   <field name="description" type="string" indexed="true" stored="false" multiValued="true"
required="false" />
+   <field name="subject" type="string" indexed="true" stored="false" multiValued="true"
required="false" />
+   <field name="creator" type="string" indexed="true" stored="false" multiValued="true"
required="false" />
+   <field name="publisher" type="string" indexed="true" stored="false" multiValued="true"
required="false" />
+   <field name="contributor" type="string" indexed="true" stored="false" multiValued="true"
required="false" />
    
    <!-- Dynamic field definitions.  If a field name is not found, dynamicFields
         will be used if the name matches any of the patterns.
@@ -479,7 +485,9 @@
         field name or dynamic field, rather than reporting them as an error. 
         alternately, change the type="ignored" to some other type e.g. "text" if you want

         unknown fields indexed and/or stored by default --> 
+   <!--
    <dynamicField name="*" type="ignored" multiValued="true" />
+   -->
    
  </fields>
 

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/main/java/org/apache/jetspeed/search/solr/SolrSearchEngineImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/main/java/org/apache/jetspeed/search/solr/SolrSearchEngineImpl.java?rev=1094737&r1=1094736&r2=1094737&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/main/java/org/apache/jetspeed/search/solr/SolrSearchEngineImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/main/java/org/apache/jetspeed/search/solr/SolrSearchEngineImpl.java
Mon Apr 18 20:49:40 2011
@@ -19,8 +19,10 @@ package org.apache.jetspeed.search.solr;
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -58,6 +60,21 @@ public class SolrSearchEngineImpl implem
     private SolrServer server;
     private boolean optimizeAfterUpdate = true;
     private HandlerFactory handlerFactory;
+    private Set<String> searchableMetadataFieldNames = 
+        new HashSet<String>(Arrays.asList(
+                                          "ID", 
+                                          "url", 
+                                          "portlet", 
+                                          "portlet_application",
+                                          "subject",
+                                          "creator",
+                                          "publisher",
+                                          "title",
+                                          "fieldname.title",
+                                          "contributor",
+                                          "description",
+                                          "fieldname.description"
+                                          ));
     
     public SolrSearchEngineImpl(SolrServer server, boolean optimzeAfterUpdate, HandlerFactory
handlerFactory)
     {
@@ -66,6 +83,16 @@ public class SolrSearchEngineImpl implem
         this.handlerFactory = handlerFactory;
     }
     
+    public Set<String> getSearchableMetadataFieldNames()
+    {
+        return searchableMetadataFieldNames;
+    }
+
+    public void setSearchableMetadataFieldNames(Set<String> searchableMetadataFieldNames)
+    {
+        this.searchableMetadataFieldNames = searchableMetadataFieldNames;
+    }
+
     /* (non-Javadoc)
      * @see org.apache.jetspeed.search.SearchEnging#add(java.lang.Object)
      */
@@ -463,8 +490,14 @@ public class SolrSearchEngineImpl implem
             while(keyIter.hasNext())
             {
                 Object key = keyIter.next();
+                
                 if(key != null)
                 {
+                    if (!searchableMetadataFieldNames.contains(key))
+                    {
+                        continue;
+                    }
+                    
                     Object values = fields.get(key);
                     if(values != null)
                     {

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/test/resources/solr-test-home/js/conf/schema.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/test/resources/solr-test-home/js/conf/schema.xml?rev=1094737&r1=1094736&r2=1094737&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/test/resources/solr-test-home/js/conf/schema.xml
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-search/src/test/resources/solr-test-home/js/conf/schema.xml
Mon Apr 18 20:49:40 2011
@@ -425,7 +425,8 @@
      default: a value that should be used if no value is specified
        when adding a document.
    -->
-
+   
+   <!-- Core Search Fields -->
    <field name="fieldname.key" type="string" indexed="true" stored="true" required="true"
/>
    <field name="fieldname.type" type="text" indexed="true" stored="true" required="false"
/>
    <field name="fieldname.content" type="text" indexed="true" stored="false" required="false"
/>
@@ -438,12 +439,17 @@
    <field name="fieldname.score" type="text" indexed="true" stored="false" required="false"
/>
    <field name="fieldname.className" type="text" indexed="true" stored="true" required="false"
/>
    <field name="fieldname.synthetic" type="text" indexed="true" stored="false" required="false"
/>
-   
+   <!-- Metadata Search Fields -->
    <field name="ID" type="string" indexed="true" stored="true" required="false" />
    <field name="url" type="text" indexed="true" stored="true" required="false" />
    <field name="portlet" type="string" indexed="true" stored="true" required="false" />
    <field name="portlet_application" type="string" indexed="true" stored="true" required="false"
/>
-   
+   <field name="title" type="string" indexed="true" stored="false" multiValued="true"
required="false" />
+   <field name="description" type="string" indexed="true" stored="false" multiValued="true"
required="false" />
+   <field name="subject" type="string" indexed="true" stored="false" multiValued="true"
required="false" />
+   <field name="creator" type="string" indexed="true" stored="false" multiValued="true"
required="false" />
+   <field name="publisher" type="string" indexed="true" stored="false" multiValued="true"
required="false" />
+   <field name="contributor" type="string" indexed="true" stored="false" multiValued="true"
required="false" />
    
    <!-- Dynamic field definitions.  If a field name is not found, dynamicFields
         will be used if the name matches any of the patterns.
@@ -479,7 +485,9 @@
         field name or dynamic field, rather than reporting them as an error. 
         alternately, change the type="ignored" to some other type e.g. "text" if you want

         unknown fields indexed and/or stored by default --> 
+   <!--
    <dynamicField name="*" type="ignored" multiValued="true" />
+   -->
    
  </fields>
 

Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/conf/jetspeed/jetspeed.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/conf/jetspeed/jetspeed.properties?rev=1094737&r1=1094736&r2=1094737&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/conf/jetspeed/jetspeed.properties
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/conf/jetspeed/jetspeed.properties
Mon Apr 18 20:49:40 2011
@@ -235,7 +235,8 @@ search.index.location=${applicationRoot}
 search.index.optimizeAfterUpdate=true
 
 # Optionally you can configure external solr http(s) url
-search.http.solr.url=http://localhost:8983/solr
+# Note: If you have multi-core setup, you should put the core name at the end. e.g., '/js'.
+search.http.solr.url=http://localhost:8983/solr/js
 
 # Optionally you can configure embedded solr home and data dir paths 
 # if you enable embedded solr instead of the default lucene



---------------------------------------------------------------------
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