Author: lektran
Date: Sat Sep 11 03:34:02 2010 New Revision: 996056 URL: http://svn.apache.org/viewvc?rev=996056&view=rev Log: Corrected usage of Lucene API to be compatible with our current version (2.4.1), partially resolves OFBIZ-3927 Modified: ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy 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=996056&r1=996055&r2=996056&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 Sep 11 03:34:02 2010 @@ -26,6 +26,7 @@ import org.apache.lucene.index.IndexRead import org.apache.lucene.search.Query import org.apache.lucene.search.TermQuery import org.apache.lucene.search.BooleanQuery +import org.apache.lucene.search.BooleanClause; import org.apache.lucene.index.Term import org.apache.lucene.search.Hits import org.apache.lucene.queryParser.QueryParser @@ -70,13 +71,13 @@ if (queryLine || siteId) { if (queryLine) { queryParser = new QueryParser("content", analyzer); query = queryParser.parse(queryLine); - combQuery.add(query, true, false); + combQuery.add(query, BooleanClause.Occur.MUST); } Debug.logInfo("in search, combQuery(0):" + combQuery, ""); if (siteId) { termQuery = new TermQuery(new Term("site", siteId)); - combQuery.add(termQuery, true, false); + combQuery.add(termQuery, BooleanClause.Occur.MUST); Debug.logInfo("in search, termQuery:" + termQuery.toString(), ""); } Debug.logInfo("in search, combQuery(1):" + combQuery, ""); @@ -84,28 +85,26 @@ if (queryLine || siteId) { if (searchFeature1 || searchFeature2 || searchFeature3 || !featureIdByType.isEmpty()) { featureQuery = new BooleanQuery(); - anyOrAll = paramMap.any_or_all; - featuresRequired = true; - - if (anyOrAll && "any".equals(anyOrAll)) { - featuresRequired = false; + featuresRequired = BooleanClause.Occur.MUST; + if ("any".equals(paramMap.any_or_all)) { + featuresRequired = BooleanClause.Occur.SHOULD; } if (searchFeature1) { termQuery = new TermQuery(new Term("feature", searchFeature1)); - featureQuery.add(termQuery, featuresRequired, false); + featureQuery.add(termQuery, featuresRequired); Debug.logInfo("in search searchFeature1, termQuery:" + termQuery.toString(), ""); } if (searchFeature2) { termQuery = new TermQuery(new Term("feature", searchFeature2)); - featureQuery.add(termQuery, featuresRequired, false); + featureQuery.add(termQuery, featuresRequired); Debug.logInfo("in search searchFeature2, termQuery:" + termQuery.toString(), ""); } if (searchFeature3) { termQuery = new TermQuery(new Term("feature", searchFeature3)); - featureQuery.add(termQuery, featuresRequired, false); + featureQuery.add(termQuery, featuresRequired); Debug.logInfo("in search searchFeature3, termQuery:" + termQuery.toString(), ""); } @@ -113,10 +112,10 @@ if (searchFeature1 || searchFeature2 || values = featureIdByType.values(); values.each { val -> termQuery = new TermQuery(new Term("feature", val)); - featureQuery.add(termQuery, featuresRequired, false); + featureQuery.add(termQuery, featuresRequired); Debug.logInfo("in search searchFeature3, termQuery:" + termQuery.toString(), ""); } - combQuery.add(featureQuery, featuresRequired, false); + combQuery.add(featureQuery, featuresRequired); } if (searcher) { |
Free forum by Nabble | Edit this page |