Author: jleroux
Date: Tue Apr 11 07:34:15 2017
New Revision: 1790933
URL:
http://svn.apache.org/viewvc?rev=1790933&view=revLog:
Fixed: CMS shows error screen on Product Search
(OFBIZ-9308)
Steps to regenerate:
1. Go to Content component
https://localhost:8443/content/control/main2. Click on CMS tab directing to
https://localhost:8443/content/control/CMSContentFind3. Click on Search Products subtab directing to
https://localhost:8443/content/control/ProductSearch4. Provide a Lucene Query and Click submit.
5. Screen renders with ScreenRenderingException
Problem:
1. "ProductSearch" request directs to "ProductSearch" screen in
LuceneScreens.xml.
2. On ProductSearch screen, "SearchProducts.groovy" script prepares and hits a
search query to Lucene.
3. "BooleanQuery" class is used to match documents with other boolean query
combinations.
4. BooleanQuery object is initialised with Its default constructor.
5. With Lucene 5.4.0, this constructor is deprecated.
OFBiz migrated to Lucene 6.3.1: OFBIZ-8316
Solution:
From Lucene 5.4.0 default constructor is deprecated and a new inner class
Builder is created for queries.
Refer OFBIZ-9301 for detailed explanation.
Thanks: Aditya
Modified:
ofbiz/ofbiz-plugins/trunk/lucene/groovyScripts/content/SearchProducts.groovy
Modified: ofbiz/ofbiz-plugins/trunk/lucene/groovyScripts/content/SearchProducts.groovy
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/lucene/groovyScripts/content/SearchProducts.groovy?rev=1790933&r1=1790932&r2=1790933&view=diff==============================================================================
--- ofbiz/ofbiz-plugins/trunk/lucene/groovyScripts/content/SearchProducts.groovy (original)
+++ ofbiz/ofbiz-plugins/trunk/lucene/groovyScripts/content/SearchProducts.groovy Tue Apr 11 07:34:15 2017
@@ -25,16 +25,11 @@ import org.apache.lucene.document.Docume
import org.apache.lucene.index.DirectoryReader
import org.apache.lucene.queryparser.classic.ParseException
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
-import org.apache.lucene.search.Query
-import org.apache.lucene.search.ScoreDoc
-import org.apache.lucene.search.TopScoreDocCollector
+import org.apache.lucene.search.*
import org.apache.lucene.store.FSDirectory
if (parameters.luceneQuery) {
- Query combQuery = new BooleanQuery()
+ combQuery = new BooleanQuery.Builder()
IndexSearcher searcher
WhitespaceAnalyzer analyzer
try {
@@ -58,7 +53,7 @@ if (parameters.luceneQuery) {
combQuery.add(query, BooleanClause.Occur.MUST)
TopScoreDocCollector collector = TopScoreDocCollector.create(100) // defaulting to 100 results
- searcher.search(combQuery, collector)
+ searcher.search(combQuery.build(), collector)
ScoreDoc[] hits = collector.topDocs().scoreDocs
productList = []
hits.each { hit ->