Author: jleroux
Date: Mon Apr 10 12:20:42 2017 New Revision: 1790811 URL: http://svn.apache.org/viewvc?rev=1790811&view=rev Log: "Applied fix from trunk framework for revision: 1790810 " BY HAND ------------------------------------------------------------------------ Fixed: Ecommerce component showing error screen on searchContent from showcontenttree page (OFBIZ-9309) Steps to reproduce: 1.Go to Ecommerce component https://localhost:8443/ecommerce/control/main 2.Click on any of the Content from "Browse Content" section of left panel. It will be directed to https://localhost:8443/ecommerce/control/showcontenttree?contentId=STORE_POLICIES&nodeTrailCsv=STORE_POLICIES 3. Click on Search, it directs to https://localhost:8443/ecommerce/control/searchContent?siteId=STORE_POLICIES 4. Screen renders with ScreenRenderingException Problem: 1. "searchContent" request directs to "searchContent" screen in ContentScreens.xml. 2. On searchContent screen, "/ecommerce/groovyScripts/content/Search.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/branches/release16.11/ (props changed) ofbiz/branches/release16.11/specialpurpose/ecommerce/groovyScripts/content/Search.groovy Propchange: ofbiz/branches/release16.11/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Mon Apr 10 12:20:42 2017 @@ -10,5 +10,5 @@ /ofbiz/branches/json-integration-refactoring:1634077-1635900 /ofbiz/branches/multitenant20100310:921280-927264 /ofbiz/branches/release13.07:1547657 -/ofbiz/ofbiz-framework/trunk:1783202,1783388,1784549,1784558,1784708,1785882,1785925,1786079,1786214,1786525,1787047,1787133,1787176,1787535,1787906-1787911,1787949,1789665,1789863,1789874 +/ofbiz/ofbiz-framework/trunk:1783202,1783388,1784549,1784558,1784708,1785882,1785925,1786079,1786214,1786525,1787047,1787133,1787176,1787535,1787906-1787911,1787949,1789665,1789863,1789874,1790810 /ofbiz/trunk:1770481,1770490,1770540,1771440,1771448,1771516,1771935,1772346,1772880,1774772,1775441,1779724,1780659,1781109,1781125,1781979,1782498,1782520 Modified: ofbiz/branches/release16.11/specialpurpose/ecommerce/groovyScripts/content/Search.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/specialpurpose/ecommerce/groovyScripts/content/Search.groovy?rev=1790811&r1=1790810&r2=1790811&view=diff ============================================================================== --- ofbiz/branches/release16.11/specialpurpose/ecommerce/groovyScripts/content/Search.groovy (original) +++ ofbiz/branches/release16.11/specialpurpose/ecommerce/groovyScripts/content/Search.groovy Mon Apr 10 12:20:42 2017 @@ -30,6 +30,7 @@ import org.apache.ofbiz.product.feature. import org.apache.lucene.search.* import org.apache.lucene.index.DirectoryReader import org.apache.lucene.store.Directory +import org.apache.ofbiz.base.util.UtilProperties paramMap = UtilHttp.getParameterMap(request) queryLine = paramMap.queryLine.toString() @@ -40,19 +41,20 @@ siteId = paramMap.siteId ?: "WebStoreCON featureIdByType = ParametricSearch.makeFeatureIdByTypeMap(paramMap) //Debug.logInfo("in search, featureIdByType:" + featureIdByType, "") -combQuery = new BooleanQuery() -Directory directory = FSDirectory.open(new File(SearchWorker.getIndexPath("content")).toPath()) -DirectoryReader reader = DirectoryReader.open(directory) +combQuery = new BooleanQuery.Builder() IndexSearcher searcher = null Analyzer analyzer = null try { + Directory directory = FSDirectory.open(new File(SearchWorker.getIndexPath("content")).toPath()) + DirectoryReader reader = DirectoryReader.open(directory) searcher = new IndexSearcher(reader) analyzer = new StandardAnalyzer() } catch (java.io.FileNotFoundException e) { - Debug.logError(e, "Search.groovy") - request.setAttribute("errorMsgReq", "No index file exists.") + context.errorMessageList.add(UtilProperties.getMessage("ContentErrorUiLabels", "ContentSearchNotIndexed", locale)) + return } + termQuery = new TermQuery(new Term("site", siteId.toString())) combQuery.add(termQuery, BooleanClause.Occur.MUST) //Debug.logInfo("in search, termQuery:" + termQuery.toString(), "") @@ -66,7 +68,7 @@ if (queryLine && analyzer) { } if (featureIdByType) { - featureQuery = new BooleanQuery() + featureQuery = new BooleanQuery.Builder() featuresRequired = BooleanClause.Occur.MUST if ("any".equals(paramMap.anyOrAll)) { featuresRequired = BooleanClause.Occur.SHOULD @@ -79,13 +81,13 @@ if (featureIdByType) { //Debug.logInfo("in search searchFeature3, termQuery:" + termQuery.toString(), "") } } - combQuery.add(featureQuery, featuresRequired) + combQuery.add(featureQuery.build(), featuresRequired) } if (searcher) { Debug.logInfo("in search searchFeature3, combQuery:" + combQuery.toString(), "") TopScoreDocCollector collector = TopScoreDocCollector.create(100) //defaulting to 100 results - searcher.search(combQuery, collector) + searcher.search(combQuery.build(), collector) ScoreDoc[] hits = collector.topDocs().scoreDocs Debug.logInfo("in search, hits:" + collector.getTotalHits(), "") |
Free forum by Nabble | Edit this page |