You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/07/17 09:54:25 UTC
svn commit: r556839 - in /ofbiz/trunk: ./ applications/content/lib/
applications/content/src/org/ofbiz/content/search/
Author: jacopoc
Date: Tue Jul 17 00:54:23 2007
New Revision: 556839
URL: http://svn.apache.org/viewvc?view=rev&rev=556839
Log:
Upgrade to Apache Lucene 2.2.0
Thanks to Michael Brohl for the patch (OFBIZ-1123).
Added:
ofbiz/trunk/applications/content/lib/lucene-2.2.0.jar (with props)
Modified:
ofbiz/trunk/LICENSE
ofbiz/trunk/NOTICE
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
Modified: ofbiz/trunk/LICENSE
URL: http://svn.apache.org/viewvc/ofbiz/trunk/LICENSE?view=diff&rev=556839&r1=556838&r2=556839
==============================================================================
--- ofbiz/trunk/LICENSE (original)
+++ ofbiz/trunk/LICENSE Tue Jul 17 00:54:23 2007
@@ -83,7 +83,7 @@
ofbiz/trunk/framework/webapp/lib/ws-commons-util-1.0.1.jar
ofbiz/trunk/framework/geronimo/lib/geronimo-transaction-1.0.jar
ofbiz/trunk/framework/geronimo/lib/jencks-1.1.3.jar
-ofbiz/trunk/applications/content/lib/lucene.jar
+ofbiz/trunk/applications/content/lib/lucene-2.2.0.jar
ofbiz/trunk/applications/content/lib/poi.jar
==========================================================================
Apache License
Modified: ofbiz/trunk/NOTICE
URL: http://svn.apache.org/viewvc/ofbiz/trunk/NOTICE?view=diff&rev=556839&r1=556838&r2=556839
==============================================================================
--- ofbiz/trunk/NOTICE (original)
+++ ofbiz/trunk/NOTICE Tue Jul 17 00:54:23 2007
@@ -104,6 +104,16 @@
to the public at http://java.sun.com/docs/books/jni.
=========================================================================
+== Apache Lucene Notice ==
+=========================================================================
+
+The snowball stemmers in
+ contrib/snowball/src/java/net/sf/snowball
+were developed by Martin Porter and Richard Boulton.
+The full snowball package is available from
+ http://snowball.tartarus.org/
+
+=========================================================================
== Apache Xerces Java Notice ==
=========================================================================
Added: ofbiz/trunk/applications/content/lib/lucene-2.2.0.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/lucene-2.2.0.jar?view=auto&rev=556839
==============================================================================
Binary file - no diff available.
Propchange: ofbiz/trunk/applications/content/lib/lucene-2.2.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?view=diff&rev=556839&r1=556838&r2=556839
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java Tue Jul 17 00:54:23 2007
@@ -40,6 +40,9 @@
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;
/**
* ContentDocument Class
@@ -49,9 +52,9 @@
static char dirSep = System.getProperty("file.separator").charAt(0);
public static final String module = ContentDocument.class.getName();
-
+
public static Document Document(String id, GenericDelegator delegator, LocalDispatcher dispatcher) throws InterruptedException {
-
+
Document doc = null;
GenericValue content;
try {
@@ -60,19 +63,19 @@
Debug.logError(e, module);
return doc;
}
-
+
Map map = new HashMap();
doc = Document(content, map, dispatcher);
return doc;
}
-
+
public static Document Document(GenericValue content, Map context, LocalDispatcher dispatcher) throws InterruptedException {
Document doc;
// make a new, empty document
doc = new Document();
String contentId = content.getString("contentId");
- doc.add(Field.Keyword("contentId", contentId));
+ doc.add(new Field("contentId", contentId, Store.YES, Index.UN_TOKENIZED, TermVector.NO));
// 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
@@ -83,14 +86,14 @@
modDate = (Timestamp) content.get("createdDate");
}
if (modDate != null) {
- doc.add(Field.Keyword("modified", modDate.toString()));
+ doc.add(new Field("modified", modDate.toString(), Store.YES, Index.UN_TOKENIZED, TermVector.NO));
}
String contentName = content.getString("contentName");
if (UtilValidate.isNotEmpty(contentName))
- doc.add(Field.Text("title", contentName));
+ doc.add(new Field("title", contentName, Store.YES, Index.TOKENIZED, TermVector.NO));
String description = content.getString("description");
if (UtilValidate.isNotEmpty(description))
- doc.add(Field.Text("description", description));
+ doc.add(new Field("description", description, Store.YES, Index.TOKENIZED, TermVector.NO));
List ancestorList = new ArrayList();
GenericDelegator delegator = content.getDelegator();
ContentWorker.getContentAncestryAll(delegator, contentId, "WEB_SITE_PUB_PT", "TO", ancestorList);
@@ -98,7 +101,7 @@
//Debug.logInfo("in ContentDocument, ancestorString:" + ancestorString,
// module);
if (UtilValidate.isNotEmpty(ancestorString)) {
- Field field = Field.UnStored("site", ancestorString);
+ Field field = new Field("site", ancestorString, Store.NO, Index.TOKENIZED, TermVector.NO);
//Debug.logInfo("in ContentDocument, field:" + field.stringValue(),
// module);
doc.add(field);
@@ -161,7 +164,7 @@
}
//Debug.logInfo("in DataResourceDocument, text:" + text, module);
if (UtilValidate.isNotEmpty(text)) {
- Field field = Field.UnStored("content", text);
+ Field field = new Field("content", text, Store.NO, Index.TOKENIZED, TermVector.NO);
//Debug.logInfo("in ContentDocument, field:" + field.stringValue(), module);
doc.add(field);
}
@@ -184,7 +187,7 @@
String featureString = StringUtil.join(featureList, " ");
//Debug.logInfo("in ContentDocument, featureString:" + featureString, module);
if (UtilValidate.isNotEmpty(featureString)) {
- Field field = Field.UnStored("feature", featureString);
+ Field field = new Field("feature", featureString, Store.NO, Index.TOKENIZED, TermVector.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?view=diff&rev=556839&r1=556838&r2=556839
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java Tue Jul 17 00:54:23 2007
@@ -35,6 +35,9 @@
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;
/**
* DataResourceDocument Class
@@ -43,9 +46,9 @@
public class DataResourceDocument {
static char dirSep = System.getProperty("file.separator").charAt(0);
public static final String module = ContentDocument.class.getName();
-
+
public static Document Document(String id, GenericDelegator delegator, Map context) throws InterruptedException {
-
+
Document doc = null;
GenericValue dataResource = null;
try {
@@ -56,9 +59,9 @@
}
// make a new, empty document
doc = new Document();
-
- doc.add(Field.Keyword("dataResourceId", id));
-
+
+ doc.add(new Field("dataResourceId", id, Store.YES, Index.UN_TOKENIZED, TermVector.NO));
+
String mimeTypeId = dataResource.getString("mimeTypeId");
if (UtilValidate.isEmpty(mimeTypeId)) {
mimeTypeId = "text/html";
@@ -69,7 +72,7 @@
if (UtilValidate.isNotEmpty(currentLocaleString)) {
locale = UtilMisc.parseLocale(currentLocaleString);
}
-
+
StringWriter outWriter = new StringWriter();
try {
DataResourceWorker.writeDataResourceText(dataResource, mimeTypeId, locale, context, delegator, outWriter, true);
@@ -80,9 +83,9 @@
}
String text = outWriter.toString();
Debug.logInfo("in DataResourceDocument, text:" + text, module);
- if (UtilValidate.isNotEmpty(text))
- doc.add(Field.UnStored("content", text));
-
+ if (UtilValidate.isNotEmpty(text))
+ doc.add(new Field("content", text, Store.NO, Index.TOKENIZED, TermVector.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?view=diff&rev=556839&r1=556838&r2=556839
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java Tue Jul 17 00:54:23 2007
@@ -6,9 +6,9 @@
* to you 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
@@ -70,11 +70,11 @@
Iterator iter2 = subContentList.iterator();
while (iter2.hasNext()) {
GenericValue subContent = (GenericValue)iter2.next();
- contentIdList.add(subContent.getString("contentId"));
+ contentIdList.add(subContent.getString("contentId"));
}
//if (Debug.infoOn()) Debug.logInfo("in indexTree, contentIdList:" + contentIdList, module);
indexContentList(contentIdList, delegator, dispatcher, context);
-
+
String subSiteId = siteContent.getString("contentId");
indexTree(dispatcher, delegator, subSiteId, context, path);
} else {
@@ -91,12 +91,12 @@
//if (Debug.infoOn()) Debug.logInfo("in indexTree, results:" + results, module);
return results;
}
-
+
public static void indexContentList(List idList, GenericDelegator delegator, LocalDispatcher dispatcher, Map context) throws Exception {
String path = null;
indexContentList(dispatcher, delegator, context, idList, path);
}
-
+
public static void indexContentList(LocalDispatcher dispatcher, GenericDelegator delegator, Map context, List idList, String path) throws Exception {
String indexAllPath = getIndexPath(path);
if (Debug.infoOn())
@@ -152,8 +152,8 @@
writer.optimize();
writer.close();
}
-
-
+
+
public static void deleteContentDocument(GenericValue content, String path) throws Exception {
String indexAllPath = null;
indexAllPath = getIndexPath(path);
@@ -161,12 +161,12 @@
deleteContentDocument(content, reader);
reader.close();
}
-
+
public static void deleteContentDocument(GenericValue content, IndexReader reader) throws Exception {
String contentId = content.getString("contentId");
Term term = new Term("contentId", contentId);
if (Debug.infoOn()) Debug.logInfo("in indexContent, term:" + term, module);
- int qtyDeleted = reader.delete(term);
+ int qtyDeleted = reader.deleteDocuments(term);
if (Debug.infoOn()) Debug.logInfo("in indexContent, qtyDeleted:" + term, module);
String dataResourceId = content.getString("dataResourceId");
if (dataResourceId != null) {
@@ -174,12 +174,12 @@
}
}
-
+
public static void deleteDataResourceDocument(String dataResourceId, IndexReader reader) throws Exception {
Term term = new Term("dataResourceId", dataResourceId);
if (Debug.infoOn()) Debug.logInfo("in indexContent, term:" + term, module);
- int qtyDeleted = reader.delete(term);
+ int qtyDeleted = reader.deleteDocuments(term);
if (Debug.infoOn()) Debug.logInfo("in indexContent, qtyDeleted:" + term, module);
}
@@ -194,12 +194,12 @@
writer = new IndexWriter(indexAllPath, new StandardAnalyzer(), true);
if (Debug.infoOn()) Debug.logInfo("Created new directory:" + indexAllPath, module);
}
-
+
indexContent(dispatcher, delegator, context, content, writer);
writer.optimize();
writer.close();
}
-
+
public static void indexContent(LocalDispatcher dispatcher, GenericDelegator delegator, Map context, GenericValue content, IndexWriter writer) throws Exception {
Document doc = ContentDocument.Document(content, context, dispatcher);
//if (Debug.infoOn()) Debug.logInfo("in indexContent, content:" + content, module);
@@ -216,14 +216,14 @@
indexDataResource(delegator, context, dataResourceId, writer);
}
*/
-
+
}
-
+
public static void indexDataResource(GenericDelegator delegator, Map context, String id) throws Exception {
String path = null;
indexDataResource(delegator, context, id, path );
}
-
+
public static void indexDataResource(GenericDelegator delegator, Map context, String id, String path) throws Exception {
String indexAllPath = getIndexPath(path);
IndexWriter writer = null;
@@ -231,7 +231,7 @@
writer = new IndexWriter(indexAllPath, new StandardAnalyzer(), false);
} catch(FileNotFoundException e) {
writer = new IndexWriter(indexAllPath, new StandardAnalyzer(), true);
- }
+ }
indexDataResource(delegator, context, id, writer);
writer.optimize();
writer.close();
@@ -242,7 +242,7 @@
Document doc = DataResourceDocument.Document(id, delegator, context);
writer.addDocument(doc);
}
-
+
public static String getIndexPath(String path) {
String indexAllPath = path;
if (UtilValidate.isEmpty(indexAllPath))