You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Jacopo Cappellato <ja...@hotwaxmedia.com> on 2012/08/17 17:00:16 UTC
Inconsistent (?) use of Lucene versions
Hi all,
while reviewing the OFBiz code that implements the integration with Lucene I have noticed some inconsistent usage of the Lucene Version: some code sets the version to 30, 34, 35 while the current version we are using in OFBiz is 35 (aka Lucene 3.5); is this done intentionally or it is a result of incomplete upgrades (as I suspect)?
Here is the code that I would like to commit to fix the issue (if it is an issue), that will also make it easier to perform new upgrades: [*]
What do you think? All tests pass with this change but I have very few experience of this integration and I would appreciate your feedback.
Thanks,
Jacopo
[*]:
Index: applications/content/src/org/ofbiz/content/search/SearchWorker.java
===================================================================
--- applications/content/src/org/ofbiz/content/search/SearchWorker.java (revision 1374283)
+++ applications/content/src/org/ofbiz/content/search/SearchWorker.java (working copy)
@@ -58,6 +58,8 @@
public static final String module = SearchWorker.class.getName();
+ public static final Version LUCENE_VERSION = Version.LUCENE_35;
+
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();
GenericValue content = delegator.makeValue("Content", UtilMisc.toMap("contentId", siteId));
@@ -130,8 +129,8 @@
// Now create
IndexWriter writer = null;
long savedWriteLockTimeout = IndexWriterConfig.getDefaultWriteLockTimeout();
- Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_34);
- IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_34, analyzer);
+ Analyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
+ IndexWriterConfig conf = new IndexWriterConfig(LUCENE_VERSION, analyzer);
try {
IndexWriterConfig.setDefaultWriteLockTimeout(2000);
@@ -176,8 +175,8 @@
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);
+ Analyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
+ IndexWriterConfig conf = new IndexWriterConfig(LUCENE_VERSION, analyzer);
IndexWriter writer = null;
try {
try {
@@ -227,8 +226,8 @@
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);
+ Analyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
+ IndexWriterConfig conf = new IndexWriterConfig(LUCENE_VERSION, analyzer);
IndexWriter writer = null;
try {
Index: applications/content/src/org/ofbiz/content/test/LuceneTests.java
===================================================================
--- applications/content/src/org/ofbiz/content/test/LuceneTests.java (revision 1373891)
+++ applications/content/src/org/ofbiz/content/test/LuceneTests.java (working copy)
@@ -85,9 +85,9 @@
String queryLine = "hand";
IndexSearcher searcher = new IndexSearcher(r);
- Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_35);
+ Analyzer analyzer = new StandardAnalyzer(SearchWorker.LUCENE_VERSION);
- QueryParser parser = new QueryParser(Version.LUCENE_35, "content", analyzer);
+ QueryParser parser = new QueryParser(SearchWorker.LUCENE_VERSION, "content", analyzer);
Query query = parser.parse(queryLine);
combQuery.add(query, BooleanClause.Occur.MUST);
Index: applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy
===================================================================
--- applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy (revision 1373891)
+++ applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy (working copy)
@@ -56,7 +56,7 @@
Debug.logInfo("in search, indexPath:" + directory.toString(), "");
searcher = new IndexSearcher(reader);
Debug.logInfo("in search, searcher:" + searcher, "");
- analyzer = new StandardAnalyzer(Version.LUCENE_30);
+ analyzer = new StandardAnalyzer(SearchWorker.LUCENE_VERSION);
} catch (java.io.FileNotFoundException e) {
request.setAttribute("errorMsgReq", "No index file exists.");
Debug.logError("in search, error:" + e.getMessage(), "");
@@ -66,7 +66,7 @@
if (queryLine || siteId) {
Query query = null;
if (queryLine) {
- QueryParser parser = new QueryParser(Version.LUCENE_30, "content", analyzer);
+ QueryParser parser = new QueryParser(SearchWorker.LUCENE_VERSION, "content", analyzer);
query = parser.parse(queryLine);
combQuery.add(query, BooleanClause.Occur.MUST);
}
Index: specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy
===================================================================
--- specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy (revision 1373891)
+++ specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy (working copy)
@@ -57,7 +57,7 @@
Analyzer analyzer = null;
try {
searcher = new IndexSearcher(reader);
- analyzer = new StandardAnalyzer(Version.LUCENE_30);
+ analyzer = new StandardAnalyzer(SearchWorker.LUCENE_VERSION);
} catch (java.io.FileNotFoundException e) {
Debug.logError(e, "Search.groovy");
request.setAttribute("errorMsgReq", "No index file exists.");
@@ -69,7 +69,7 @@
//Debug.logInfo("in search, combQuery(1):" + combQuery, "");
if (queryLine && analyzer) {
Query query = null;
- QueryParser parser = new QueryParser(Version.LUCENE_30, "content", analyzer);
+ QueryParser parser = new QueryParser(SearchWorker.LUCENE_VERSION, "content", analyzer);
query = parser.parse(queryLine);
combQuery.add(query, BooleanClause.Occur.MUST);
}
Re: Inconsistent (?) use of Lucene versions
Posted by Jacopo Cappellato <ja...@hotwaxmedia.com>.
Mirko, Erwan,
thank you for your feedback. I have committed my code changes with rev. 1374328
Jacopo
On Aug 17, 2012, at 5:30 PM, Erwan de FERRIERES wrote:
> Le 17/08/2012 17:11, Mirko Vogelsmeier a écrit :
>> Hi Jacopo,
>>
>> +1 to that change.
>> I would go even further to prevent these inconsistencies in later updates
>> and move
>> the groovy-Code to the java-Sources to get propper compiling errors.
>> Also there are already a couple of newer Lucene Versions out (eg.
>> Lucene-4.0-ALPHA).
>> I can provide some patches to upgrade to that release.
>>
>> Greetings,
>> Mirko
>>
>
> Mirko,
>
> please create a jira issue for upgrading to newer release, at least 3.6.1. I will then review it.
>
> Cheers,
>
>
> --
> Erwan de FERRIERES
> www.nereide.biz
Re: Inconsistent (?) use of Lucene versions
Posted by Erwan de FERRIERES <er...@nereide.fr>.
Le 17/08/2012 17:11, Mirko Vogelsmeier a écrit :
> Hi Jacopo,
>
> +1 to that change.
> I would go even further to prevent these inconsistencies in later updates
> and move
> the groovy-Code to the java-Sources to get propper compiling errors.
> Also there are already a couple of newer Lucene Versions out (eg.
> Lucene-4.0-ALPHA).
> I can provide some patches to upgrade to that release.
>
> Greetings,
> Mirko
>
Mirko,
please create a jira issue for upgrading to newer release, at least
3.6.1. I will then review it.
Cheers,
--
Erwan de FERRIERES
www.nereide.biz
Re: Inconsistent (?) use of Lucene versions
Posted by Mirko Vogelsmeier <mi...@lynx.de>.
Hi Jacopo,
+1 to that change.
I would go even further to prevent these inconsistencies in later updates
and move
the groovy-Code to the java-Sources to get propper compiling errors.
Also there are already a couple of newer Lucene Versions out (eg.
Lucene-4.0-ALPHA).
I can provide some patches to upgrade to that release.
Greetings,
Mirko
Mirko Vogelsmeier
Consultant
Lynx-Consulting GmbH
Johanniskirchplatz 6
33615 Bielefeld
Deutschland
Fon: +49 521 5247-0
Fax: +49 521 5247-250
Mobil:
Company and Management Headquarters:
Lynx-Consulting GmbH, Johanniskirchplatz 6, 33615 Bielefeld, Deutschland
Fon: +49 521 5247-0, Fax: +49 521 5247-250, www.lynx.de
Court Registration: Amtsgericht Bielefeld HRB 35946
Chief Executive Officer: Hans-Joachim Rosowski
From: Jacopo Cappellato <ja...@hotwaxmedia.com>
To: dev@ofbiz.apache.org
Date: 17.08.2012 17:01
Subject: Inconsistent (?) use of Lucene versions
Hi all,
while reviewing the OFBiz code that implements the integration with Lucene
I have noticed some inconsistent usage of the Lucene Version: some code
sets the version to 30, 34, 35 while the current version we are using in
OFBiz is 35 (aka Lucene 3.5); is this done intentionally or it is a result
of incomplete upgrades (as I suspect)?
Here is the code that I would like to commit to fix the issue (if it is an
issue), that will also make it easier to perform new upgrades: [*]
What do you think? All tests pass with this change but I have very few
experience of this integration and I would appreciate your feedback.
Thanks,
Jacopo
[*]:
Index: applications/content/src/org/ofbiz/content/search/SearchWorker.java
===================================================================
--- applications/content/src/org/ofbiz/content/search/SearchWorker.java
(revision 1374283)
+++ applications/content/src/org/ofbiz/content/search/SearchWorker.java
(working copy)
@@ -58,6 +58,8 @@
public static final String module = SearchWorker.class.getName();
+ public static final Version LUCENE_VERSION = Version.LUCENE_35;
+
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();
GenericValue content = delegator.makeValue("Content",
UtilMisc.toMap("contentId", siteId));
@@ -130,8 +129,8 @@
// Now create
IndexWriter writer = null;
long savedWriteLockTimeout =
IndexWriterConfig.getDefaultWriteLockTimeout();
- Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_34);
- IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_34,
analyzer);
+ Analyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
+ IndexWriterConfig conf = new IndexWriterConfig(LUCENE_VERSION,
analyzer);
try {
IndexWriterConfig.setDefaultWriteLockTimeout(2000);
@@ -176,8 +175,8 @@
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);
+ Analyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
+ IndexWriterConfig conf = new IndexWriterConfig(LUCENE_VERSION,
analyzer);
IndexWriter writer = null;
try {
try {
@@ -227,8 +226,8 @@
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);
+ Analyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
+ IndexWriterConfig conf = new IndexWriterConfig(LUCENE_VERSION,
analyzer);
IndexWriter writer = null;
try {
Index: applications/content/src/org/ofbiz/content/test/LuceneTests.java
===================================================================
--- applications/content/src/org/ofbiz/content/test/LuceneTests.java
(revision 1373891)
+++ applications/content/src/org/ofbiz/content/test/LuceneTests.java
(working copy)
@@ -85,9 +85,9 @@
String queryLine = "hand";
IndexSearcher searcher = new IndexSearcher(r);
- Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_35);
+ Analyzer analyzer = new
StandardAnalyzer(SearchWorker.LUCENE_VERSION);
- QueryParser parser = new QueryParser(Version.LUCENE_35,
"content", analyzer);
+ QueryParser parser = new QueryParser(SearchWorker.LUCENE_VERSION,
"content", analyzer);
Query query = parser.parse(queryLine);
combQuery.add(query, BooleanClause.Occur.MUST);
Index:
applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy
===================================================================
--- applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy
(revision 1373891)
+++ applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy
(working copy)
@@ -56,7 +56,7 @@
Debug.logInfo("in search, indexPath:" + directory.toString(), "");
searcher = new IndexSearcher(reader);
Debug.logInfo("in search, searcher:" + searcher, "");
- analyzer = new StandardAnalyzer(Version.LUCENE_30);
+ analyzer = new StandardAnalyzer(SearchWorker.LUCENE_VERSION);
} catch (java.io.FileNotFoundException e) {
request.setAttribute("errorMsgReq", "No index file exists.");
Debug.logError("in search, error:" + e.getMessage(), "");
@@ -66,7 +66,7 @@
if (queryLine || siteId) {
Query query = null;
if (queryLine) {
- QueryParser parser = new QueryParser(Version.LUCENE_30,
"content", analyzer);
+ QueryParser parser = new QueryParser(SearchWorker.LUCENE_VERSION,
"content", analyzer);
query = parser.parse(queryLine);
combQuery.add(query, BooleanClause.Occur.MUST);
}
Index:
specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy
===================================================================
---
specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy
(revision 1373891)
+++
specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy
(working copy)
@@ -57,7 +57,7 @@
Analyzer analyzer = null;
try {
searcher = new IndexSearcher(reader);
- analyzer = new StandardAnalyzer(Version.LUCENE_30);
+ analyzer = new StandardAnalyzer(SearchWorker.LUCENE_VERSION);
} catch (java.io.FileNotFoundException e) {
Debug.logError(e, "Search.groovy");
request.setAttribute("errorMsgReq", "No index file exists.");
@@ -69,7 +69,7 @@
//Debug.logInfo("in search, combQuery(1):" + combQuery, "");
if (queryLine && analyzer) {
Query query = null;
- QueryParser parser = new QueryParser(Version.LUCENE_30, "content",
analyzer);
+ QueryParser parser = new QueryParser(SearchWorker.LUCENE_VERSION,
"content", analyzer);
query = parser.parse(queryLine);
combQuery.add(query, BooleanClause.Occur.MUST);
}
Besuchen Sie unsere neue Microsite zum Thema E-Bilanz und XBRL-Browser. Ab jetzt sind Bilanz und GuV nur noch elektronisch an die Finanzbehörden zu übermitteln. Wir helfen weiter!
http://www.lynx.de/haftungsausschluss
Re: Inconsistent (?) use of Lucene versions
Posted by Erwan de FERRIERES <er...@nereide.fr>.
Le 17/08/2012 17:00, Jacopo Cappellato a écrit :
> Hi all,
>
> while reviewing the OFBiz code that implements the integration with Lucene I have noticed some inconsistent usage of the Lucene Version: some code sets the version to 30, 34, 35 while the current version we are using in OFBiz is 35 (aka Lucene 3.5); is this done intentionally or it is a result of incomplete upgrades (as I suspect)?
>
> Here is the code that I would like to commit to fix the issue (if it is an issue), that will also make it easier to perform new upgrades: [*]
> What do you think? All tests pass with this change but I have very few experience of this integration and I would appreciate your feedback.
>
> Thanks,
>
> Jacopo
Hi Jacopo,
I saw that too earlier this week, but didn't have the time to work on it.
+1 for that change, I think I may have forgotten to upgrade the version.
--
Erwan de FERRIERES
www.nereide.biz