You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by er...@apache.org on 2012/11/03 22:50:24 UTC
svn commit: r1405428 - in /ofbiz/trunk: ./ applications/content/lib/
applications/content/src/org/ofbiz/content/search/
applications/content/src/org/ofbiz/content/test/
applications/content/webapp/content/WEB-INF/actions/cms/
specialpurpose/ecommerce/w...
Author: erwan
Date: Sat Nov 3 21:50:23 2012
New Revision: 1405428
URL: http://svn.apache.org/viewvc?rev=1405428&view=rev
Log:
Upgrading to latest stable Apache lucene version
Added:
ofbiz/trunk/applications/content/lib/lucene-analyzers-common-4.0.0.jar (with props)
ofbiz/trunk/applications/content/lib/lucene-core-4.0.0.jar (with props)
ofbiz/trunk/applications/content/lib/lucene-queryparser-4.0.0.jar (with props)
Removed:
ofbiz/trunk/applications/content/lib/lucene-core-3.6.1.jar
Modified:
ofbiz/trunk/.classpath
ofbiz/trunk/LICENSE
ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java
ofbiz/trunk/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java
ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java
ofbiz/trunk/applications/content/src/org/ofbiz/content/test/LuceneTests.java
ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy
ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy
Modified: ofbiz/trunk/.classpath
URL: http://svn.apache.org/viewvc/ofbiz/trunk/.classpath?rev=1405428&r1=1405427&r2=1405428&view=diff
==============================================================================
--- ofbiz/trunk/.classpath (original)
+++ ofbiz/trunk/.classpath Sat Nov 3 21:50:23 2012
@@ -4,7 +4,9 @@
<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.6.1.jar"/>
+ <classpathentry kind="lib" path="applications/content/lib/lucene-analyzers-common-4.0.0.jar"/>
+ <classpathentry kind="lib" path="applications/content/lib/lucene-core-4.0.0.jar"/>
+ <classpathentry kind="lib" path="applications/content/lib/lucene-queryparser-4.0.0.jar"/>
<classpathentry kind="lib" path="applications/content/lib/pdfbox-1.4.0.jar"/>
<classpathentry kind="lib" path="applications/content/lib/dom4j-1.6.1.jar"/>
<classpathentry kind="lib" path="applications/content/lib/poi-3.8-20120326.jar"/>
Modified: ofbiz/trunk/LICENSE
URL: http://svn.apache.org/viewvc/ofbiz/trunk/LICENSE?rev=1405428&r1=1405427&r2=1405428&view=diff
==============================================================================
--- ofbiz/trunk/LICENSE (original)
+++ ofbiz/trunk/LICENSE Sat Nov 3 21:50:23 2012
@@ -104,7 +104,9 @@ ofbiz/trunk/framework/geronimo/lib/geron
ofbiz/trunk/framework/geronimo/lib/geronimo-transaction-2.1.1.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.6.1.jar
+ofbiz/trunk/applications/content/lib/lucene-analyzers-common-4.0.0.jar
+ofbiz/trunk/applications/content/lib/lucene-core-4.0.0.jar
+ofbiz/trunk/applications/content/lib/lucene-queryparser-4.0.0.jar
ofbiz/trunk/applications/content/lib/pdfbox-1.4.0.jar
ofbiz/trunk/applications/content/lib/poi-3.8-20120326.jar
ofbiz/trunk/applications/content/lib/poi-ooxml-3.8-20120326.jar
Added: ofbiz/trunk/applications/content/lib/lucene-analyzers-common-4.0.0.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/lucene-analyzers-common-4.0.0.jar?rev=1405428&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ofbiz/trunk/applications/content/lib/lucene-analyzers-common-4.0.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ofbiz/trunk/applications/content/lib/lucene-core-4.0.0.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/lucene-core-4.0.0.jar?rev=1405428&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ofbiz/trunk/applications/content/lib/lucene-core-4.0.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ofbiz/trunk/applications/content/lib/lucene-queryparser-4.0.0.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/lucene-queryparser-4.0.0.jar?rev=1405428&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ofbiz/trunk/applications/content/lib/lucene-queryparser-4.0.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java?rev=1405428&r1=1405427&r2=1405428&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java Sat Nov 3 21:50:23 2012
@@ -41,9 +41,9 @@ import org.ofbiz.service.LocalDispatcher
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import org.apache.lucene.document.Field.Index;
import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.document.Field.TermVector;
+import org.apache.lucene.document.StringField;
+import org.apache.lucene.document.TextField;
/**
* ContentDocument Class
@@ -76,7 +76,7 @@ public class ContentDocument {
// make a new, empty document
doc = new Document();
String contentId = content.getString("contentId");
- doc.add(new Field("contentId", contentId, Store.YES, Index.NOT_ANALYZED, TermVector.NO));
+ doc.add(new StringField("contentId", contentId, Store.YES));
// Add the last modified date of the file a field named "modified". Use a
// Keyword field, so that it's searchable, but so that no attempt is
// made to tokenize the field into words.
@@ -85,14 +85,14 @@ public class ContentDocument {
modDate = (Timestamp) content.get("createdDate");
}
if (modDate != null) {
- doc.add(new Field("modified", modDate.toString(), Store.YES, Index.NOT_ANALYZED, TermVector.NO));
+ doc.add(new StringField("modified", modDate.toString(), Store.YES));
}
String contentName = content.getString("contentName");
if (UtilValidate.isNotEmpty(contentName))
- doc.add(new Field("title", contentName, Store.YES, Index.ANALYZED, TermVector.NO));
+ doc.add(new TextField("title", contentName, Store.YES));
String description = content.getString("description");
if (UtilValidate.isNotEmpty(description))
- doc.add(new Field("description", description, Store.YES, Index.ANALYZED, TermVector.NO));
+ doc.add(new TextField("description", description, Store.YES));
List<String> ancestorList = FastList.newInstance();
Delegator delegator = content.getDelegator();
ContentWorker.getContentAncestryAll(delegator, contentId, "WEB_SITE_PUB_PT", "TO", ancestorList);
@@ -100,7 +100,7 @@ public class ContentDocument {
//Debug.logInfo("in ContentDocument, ancestorString:" + ancestorString,
// module);
if (UtilValidate.isNotEmpty(ancestorString)) {
- Field field = new Field("site", ancestorString, Store.NO, Index.ANALYZED, TermVector.NO);
+ Field field = new StringField("site", ancestorString, Store.NO);
//Debug.logInfo("in ContentDocument, field:" + field.stringValue(),
// module);
doc.add(field);
@@ -163,7 +163,7 @@ public class ContentDocument {
}
//Debug.logInfo("in DataResourceDocument, text:" + text, module);
if (UtilValidate.isNotEmpty(text)) {
- Field field = new Field("content", text, Store.NO, Index.ANALYZED, TermVector.NO);
+ Field field = new TextField("content", text, Store.NO);
//Debug.logInfo("in ContentDocument, field:" + field.stringValue(), module);
doc.add(field);
}
@@ -184,7 +184,7 @@ public class ContentDocument {
String featureString = StringUtil.join(featureList, " ");
//Debug.logInfo("in ContentDocument, featureString:" + featureString, module);
if (UtilValidate.isNotEmpty(featureString)) {
- Field field = new Field("feature", featureString, Store.NO, Index.ANALYZED, TermVector.NO);
+ Field field = new TextField("feature", featureString, Store.NO);
doc.add(field);
}
return true;
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java?rev=1405428&r1=1405427&r2=1405428&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java Sat Nov 3 21:50:23 2012
@@ -34,10 +34,9 @@ import org.ofbiz.entity.GenericEntityExc
import org.ofbiz.entity.GenericValue;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.Field.Index;
import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.document.Field.TermVector;
+import org.apache.lucene.document.StringField;
+import org.apache.lucene.document.TextField;
/**
* DataResourceDocument Class
@@ -60,7 +59,7 @@ public class DataResourceDocument {
// make a new, empty document
doc = new Document();
- doc.add(new Field("dataResourceId", id, Store.YES, Index.NOT_ANALYZED, TermVector.NO));
+ doc.add(new StringField("dataResourceId", id, Store.YES));
String mimeTypeId = dataResource.getString("mimeTypeId");
if (UtilValidate.isEmpty(mimeTypeId)) {
@@ -84,7 +83,7 @@ public class DataResourceDocument {
String text = outWriter.toString();
Debug.logInfo("in DataResourceDocument, text:" + text, module);
if (UtilValidate.isNotEmpty(text))
- doc.add(new Field("content", text, Store.NO, Index.ANALYZED, TermVector.NO));
+ doc.add(new TextField("content", text, Store.NO));
return doc;
}
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=1405428&r1=1405427&r2=1405428&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 Sat Nov 3 21:50:23 2012
@@ -54,7 +54,7 @@ public class SearchWorker {
public static final String module = SearchWorker.class.getName();
- public static final Version LUCENE_VERSION = Version.LUCENE_36;
+ public static final Version LUCENE_VERSION = Version.LUCENE_40;
public static Map<String, Object> indexTree(LocalDispatcher dispatcher, Delegator delegator, String siteId, Map<String, Object> context, String path) throws Exception {
Map<String, Object> results = FastMap.newInstance();
@@ -161,7 +161,7 @@ public class SearchWorker {
}
private static void deleteDocumentsByTerm(Term term, IndexWriter writer) throws Exception {
- IndexReader reader = IndexReader.open(writer, false);
+ DirectoryReader reader = DirectoryReader.open(writer, false);
int qtyBefore = reader.docFreq(term);
//deletes documents, all the rest is for logging
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=1405428&r1=1405427&r2=1405428&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 Sat Nov 3 21:50:23 2012
@@ -27,8 +27,8 @@ import javolution.util.FastMap;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
@@ -73,9 +73,9 @@ public class LuceneTests extends OFBizTe
public void testSearchTermHand() throws Exception {
Directory directory = FSDirectory.open(new File(SearchWorker.getIndexPath(null)));
- IndexReader r = null;
+ DirectoryReader r = null;
try {
- r = IndexReader.open(directory);
+ r = DirectoryReader.open(directory);
} catch (Exception e) {
// ignore
}
Modified: ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy?rev=1405428&r1=1405427&r2=1405428&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy (original)
+++ ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy Sat Nov 3 21:50:23 2012
@@ -17,12 +17,10 @@
* under the License.
*/
-import org.apache.lucene.analysis.Analyzer
import org.apache.lucene.analysis.standard.StandardAnalyzer
import org.apache.lucene.document.Document
-import org.apache.lucene.index.IndexReader
import org.apache.lucene.index.Term
-import org.apache.lucene.queryParser.QueryParser
+import org.apache.lucene.queryparser.classic.QueryParser
import org.apache.lucene.store.FSDirectory
import org.ofbiz.base.util.Debug
import org.ofbiz.base.util.UtilHttp
@@ -30,6 +28,7 @@ import org.ofbiz.content.search.SearchWo
import org.ofbiz.product.feature.ParametricSearch
import org.apache.lucene.search.*
import org.apache.lucene.store.Directory
+import org.apache.lucene.index.DirectoryReader
paramMap = UtilHttp.getParameterMap(request);
queryLine = paramMap.queryLine.toString();
@@ -47,9 +46,7 @@ Debug.logInfo("in search, featureIdByTyp
combQuery = new BooleanQuery();
Directory directory = FSDirectory.open(new File(SearchWorker.getIndexPath(null)));
-IndexReader reader = IndexReader.open(directory, true); // only searching, so read-only=true
-Searcher searcher = null;
-Analyzer analyzer = null;
+DirectoryReader reader = DirectoryReader.open(directory);
try {
Debug.logInfo("in search, indexPath:" + directory.toString(), "");
Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy?rev=1405428&r1=1405427&r2=1405428&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy Sat Nov 3 21:50:23 2012
@@ -20,9 +20,8 @@
import org.apache.lucene.analysis.Analyzer
import org.apache.lucene.analysis.standard.StandardAnalyzer
import org.apache.lucene.document.Document
-import org.apache.lucene.index.IndexReader
import org.apache.lucene.index.Term
-import org.apache.lucene.queryParser.QueryParser
+import org.apache.lucene.queryparser.classic.QueryParser
import org.apache.lucene.store.FSDirectory
import org.ofbiz.base.util.Debug
import org.ofbiz.base.util.UtilHttp
@@ -30,6 +29,8 @@ import org.ofbiz.content.search.SearchWo
import org.ofbiz.product.feature.ParametricSearch
import org.ofbiz.widget.html.HtmlFormWrapper
import org.apache.lucene.search.*
+import org.apache.lucene.index.DirectoryReader
+import org.apache.lucene.store.Directory
paramMap = UtilHttp.getParameterMap(request);
queryLine = paramMap.queryLine.toString();
@@ -51,9 +52,11 @@ featureIdByType = ParametricSearch.makeF
//Debug.logInfo("in search, featureIdByType:" + featureIdByType, "");
combQuery = new BooleanQuery();
-IndexReader reader = IndexReader.open(FSDirectory.open(new File(SearchWorker.getIndexPath(null))), true); // only searching, so read-only=true
-Searcher searcher = null;
+Directory directory = FSDirectory.open(new File(SearchWorker.getIndexPath(null)));
+DirectoryReader reader = DirectoryReader.open(directory);
+IndexSearcher searcher = null;
Analyzer analyzer = null;
+
try {
searcher = new IndexSearcher(reader);
analyzer = new StandardAnalyzer(SearchWorker.LUCENE_VERSION);