svn commit: r1226952 - in /ofbiz/trunk: ./ applications/content/lib/ applications/content/src/org/ofbiz/content/search/ applications/content/src/org/ofbiz/content/test/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1226952 - in /ofbiz/trunk: ./ applications/content/lib/ applications/content/src/org/ofbiz/content/search/ applications/content/src/org/ofbiz/content/test/

erwan
Author: erwan
Date: Tue Jan  3 21:22:59 2012
New Revision: 1226952

URL: http://svn.apache.org/viewvc?rev=1226952&view=rev
Log:
upgrade Lucene Core to 3.5.0 -- see changelog at http://lucene.apache.org/java/docs/index.html#27+November+2011+-+Lucene+Core+3.5.0

Added:
    ofbiz/trunk/applications/content/lib/lucene-core-3.5.0.jar   (with props)
Removed:
    ofbiz/trunk/applications/content/lib/lucene-core-3.0.3.jar
Modified:
    ofbiz/trunk/.classpath
    ofbiz/trunk/LICENSE
    ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/test/LuceneTests.java

Modified: ofbiz/trunk/.classpath
URL: http://svn.apache.org/viewvc/ofbiz/trunk/.classpath?rev=1226952&r1=1226951&r2=1226952&view=diff
==============================================================================
--- ofbiz/trunk/.classpath (original)
+++ ofbiz/trunk/.classpath Tue Jan  3 21:22:59 2012
@@ -4,7 +4,7 @@
     <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
     <classpathentry kind="lib" path="applications/content/lib/fontbox-1.4.0.jar"/>
     <classpathentry kind="lib" path="applications/content/lib/jempbox-1.4.0.jar"/>
-    <classpathentry kind="lib" path="applications/content/lib/lucene-core-3.0.3.jar"/>
+    <classpathentry kind="lib" path="applications/content/lib/lucene-core-3.5.0.jar"/>
     <classpathentry kind="lib" path="applications/content/lib/metadata-extractor-2.4.0-beta-1.jar"/>
     <classpathentry kind="lib" path="applications/content/lib/pdfbox-1.4.0.jar"/>
     <classpathentry kind="lib" path="applications/content/lib/poi-3.7.jar"/>

Modified: ofbiz/trunk/LICENSE
URL: http://svn.apache.org/viewvc/ofbiz/trunk/LICENSE?rev=1226952&r1=1226951&r2=1226952&view=diff
==============================================================================
--- ofbiz/trunk/LICENSE (original)
+++ ofbiz/trunk/LICENSE Tue Jan  3 21:22:59 2012
@@ -165,7 +165,7 @@ ofbiz/trunk/framework/webslinger/lib/web
 ofbiz/trunk/framework/webslinger/lib/webslinger-launcher-20091211-3897-7ab22baea4b6.jar
 ofbiz/trunk/applications/content/lib/fontbox-1.4.0.jar
 ofbiz/trunk/applications/content/lib/jempbox-1.4.0.jar
-ofbiz/trunk/applications/content/lib/lucene-core-3.0.3.jar
+ofbiz/trunk/applications/content/lib/lucene-core-3.5.0.jar
 ofbiz/trunk/applications/content/lib/metadata-extractor-2.4.0.jar
 ofbiz/trunk/applications/content/lib/pdfbox-1.4.0.jar
 ofbiz/trunk/applications/content/lib/poi-3.7.jar

Added: ofbiz/trunk/applications/content/lib/lucene-core-3.5.0.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/lucene-core-3.5.0.jar?rev=1226952&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/applications/content/lib/lucene-core-3.5.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java?rev=1226952&r1=1226951&r2=1226952&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java Tue Jan  3 21:22:59 2012
@@ -39,9 +39,11 @@ import org.ofbiz.entity.GenericValue;
 import org.ofbiz.service.LocalDispatcher;
 
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
@@ -132,10 +134,15 @@ public class SearchWorker {
         }
         // Now create
         IndexWriter writer = null;
+        long savedWriteLockTimeout = IndexWriterConfig.getDefaultWriteLockTimeout();
+        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_34);
+        IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_34, analyzer);
+
         try {
-            writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_30), false, IndexWriter.MaxFieldLength.UNLIMITED);
-        } catch (Exception e) {
-            writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_30), true, IndexWriter.MaxFieldLength.UNLIMITED);
+            IndexWriterConfig.setDefaultWriteLockTimeout(2000);
+            writer  = new IndexWriter(directory, conf);
+        } finally {
+            IndexWriterConfig.setDefaultWriteLockTimeout(savedWriteLockTimeout);
         }
 
         for (GenericValue gv : contentList) {
@@ -173,17 +180,30 @@ public class SearchWorker {
 
     public static void indexContent(LocalDispatcher dispatcher, Delegator delegator, Map<String, Object> context, GenericValue content, String path) throws Exception {
         Directory directory = FSDirectory.open(new File(getIndexPath(path)));
+        long savedWriteLockTimeout = IndexWriterConfig.getDefaultWriteLockTimeout();
+        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_35);
+        IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_35, analyzer);
         IndexWriter writer = null;
         try {
-            writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_30), false, IndexWriter.MaxFieldLength.UNLIMITED);
+            try {
+                IndexWriterConfig.setDefaultWriteLockTimeout(2000);
+                writer  = new IndexWriter(directory, conf);
+            } finally {
+                IndexWriterConfig.setDefaultWriteLockTimeout(savedWriteLockTimeout);
+            }
             if (Debug.infoOn()) Debug.logInfo("Used old directory:" + directory.toString(), module);
         } catch (FileNotFoundException e) {
-            writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_30), true, IndexWriter.MaxFieldLength.UNLIMITED);
+            try {
+                IndexWriterConfig.setDefaultWriteLockTimeout(2000);
+                writer  = new IndexWriter(directory, conf);
+            } finally {
+                IndexWriterConfig.setDefaultWriteLockTimeout(savedWriteLockTimeout);
+            }
             if (Debug.infoOn()) Debug.logInfo("Created new directory:" + directory.toString(), module);
         }
 
         indexContent(dispatcher, delegator, context, content, writer);
-        writer.optimize();
+        writer.forceMerge(1);
         writer.close();
     }
 
@@ -211,14 +231,19 @@ public class SearchWorker {
 
     public static void indexDataResource(Delegator delegator, Map<String, Object> context, String id, String path) throws Exception {
         Directory directory = FSDirectory.open(new File(getIndexPath(path)));
+        long savedWriteLockTimeout = IndexWriterConfig.getDefaultWriteLockTimeout();
+        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_35);
+        IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_35, analyzer);
         IndexWriter writer = null;
+
         try {
-            writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_30), false, IndexWriter.MaxFieldLength.UNLIMITED);
-        } catch (FileNotFoundException e) {
-            writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_30), true, IndexWriter.MaxFieldLength.UNLIMITED);
+            IndexWriterConfig.setDefaultWriteLockTimeout(2000);
+            writer  = new IndexWriter(directory, conf);
+        } finally {
+            IndexWriterConfig.setDefaultWriteLockTimeout(savedWriteLockTimeout);
         }
         indexDataResource(delegator, context, id, writer);
-        writer.optimize();
+        writer.forceMerge(1);
         writer.close();
     }
 

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/test/LuceneTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/test/LuceneTests.java?rev=1226952&r1=1226951&r2=1226952&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/test/LuceneTests.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/test/LuceneTests.java Tue Jan  3 21:22:59 2012
@@ -33,8 +33,8 @@ import org.apache.lucene.search.BooleanC
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
-import org.apache.lucene.search.Searcher;
 import org.apache.lucene.search.TopScoreDocCollector;
+import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.util.Version;
 import org.ofbiz.base.util.UtilGenerics;
@@ -73,14 +73,21 @@ public class LuceneTests extends OFBizTe
     }
 
     public void testSearchTermHand() throws Exception {
+        Directory directory = FSDirectory.open(new File(SearchWorker.getIndexPath(null)));
+        IndexReader r = null;
+        try {
+            r = IndexReader.open(directory, false);
+        } catch (Exception e) {
+            // ignore
+        }
+
         BooleanQuery combQuery = new BooleanQuery();
         String queryLine = "hand";
-        IndexReader reader = IndexReader.open(FSDirectory.open(new File(SearchWorker.getIndexPath(null))), true);
 
-        Searcher searcher = new IndexSearcher(reader);
-        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);
+        IndexSearcher searcher = new IndexSearcher(r);
+        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_35);
 
-        QueryParser parser = new QueryParser(Version.LUCENE_30, "content", analyzer);
+        QueryParser parser = new QueryParser(Version.LUCENE_35, "content", analyzer);
         Query query = parser.parse(queryLine);
         combQuery.add(query, BooleanClause.Occur.MUST);