Thanks Jacques :)

On Wed, Jul 26, 2017 at 10:56 PM, Jacques Le Roux <
jacques.le.r...@les7arts.com> wrote:

> Thanks Renuka,
>
> I also spotted something but you beat me on it :)
>
> Jacques
>
>
> Le 17/07/2017 à 15:31, Renuka Srishti a écrit :
>
>> Hii,
>>
>> I think during the solr/lucene version update, few changes are reverted
>> like *"combQuery = new BooleanQuery.Builder()" *in
>> lucene/groovyScripts/content/Search.groovy. The issue reported for the
>> same
>> changes is OFBIZ-9301 <https://issues.apache.org/jira/browse/OFBIZ-9301>.
>>
>>
>> Thanks
>>
>> On Thu, May 11, 2017 at 5:28 AM, <sh...@apache.org> wrote:
>>
>> Author: shijh
>>> Date: Wed May 10 23:58:31 2017
>>> New Revision: 1794770
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1794770&view=rev
>>> Log:
>>> Fixed: Update Apache Solr/Lucene to release 6.2.1
>>> OFBIZ-8316
>>>
>>> Updated Lucene from 6.2.1 to 6.5.1 and the point fields generated by
>>> Lucene are ok now for Solr component.
>>>
>>> Thanks: Cao Pengan for the patch and Jacques, Michael for the comments
>>> and
>>> reviews.
>>>
>>> Modified:
>>>      ofbiz/ofbiz-plugins/trunk/lucene/build.gradle
>>>      ofbiz/ofbiz-plugins/trunk/lucene/groovyScripts/content/Sear
>>> ch.groovy
>>>      ofbiz/ofbiz-plugins/trunk/lucene/groovyScripts/content/
>>> SearchProducts.groovy
>>>      ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/
>>> apache/ofbiz/content/search/ProductDocument.java
>>>      ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/
>>> apache/ofbiz/content/search/SearchWorker.java
>>>
>>> Modified: ofbiz/ofbiz-plugins/trunk/lucene/build.gradle
>>> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/
>>> lucene/build.gradle?rev=1794770&r1=1794769&r2=1794770&view=diff
>>> ============================================================
>>> ==================
>>> --- ofbiz/ofbiz-plugins/trunk/lucene/build.gradle (original)
>>> +++ ofbiz/ofbiz-plugins/trunk/lucene/build.gradle Wed May 10 23:58:31
>>> 2017
>>> @@ -17,7 +17,7 @@
>>>    * under the License.
>>>    */
>>>   dependencies {
>>> -    pluginLibsCompile 'org.apache.lucene:lucene-core:6.2.1'
>>> -    pluginLibsCompile 'org.apache.lucene:lucene-queryparser:6.2.1'
>>> -    pluginLibsCompile 'org.apache.lucene:lucene-analyzers-common:6.2.1'
>>> +    pluginLibsCompile 'org.apache.lucene:lucene-core:6.5.1'
>>> +    pluginLibsCompile 'org.apache.lucene:lucene-queryparser:6.5.1'
>>> +    pluginLibsCompile 'org.apache.lucene:lucene-analyzers-common:6.5.1'
>>>   }
>>> \ No newline at end of file
>>>
>>> Modified: ofbiz/ofbiz-plugins/trunk/lucene/groovyScripts/content/
>>> Search.groovy
>>> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/
>>> lucene/groovyScripts/content/Search.groovy?rev=1794770&r1=
>>> 1794769&r2=1794770&view=diff
>>> ============================================================
>>> ==================
>>> --- ofbiz/ofbiz-plugins/trunk/lucene/groovyScripts/content/Search.groovy
>>> (original)
>>> +++ ofbiz/ofbiz-plugins/trunk/lucene/groovyScripts/content/Search.groovy
>>> Wed May 10 23:58:31 2017
>>> @@ -22,15 +22,13 @@ import org.apache.lucene.document.Docume
>>>   import org.apache.lucene.index.Term
>>>   import org.apache.lucene.queryparser.classic.QueryParser
>>>   import org.apache.lucene.store.FSDirectory
>>> -import org.apache.lucene.search.*
>>> -import org.apache.lucene.index.DirectoryReader
>>> -
>>>   import org.apache.ofbiz.base.util.UtilHttp
>>>   import org.apache.ofbiz.content.search.SearchWorker
>>>   import org.apache.ofbiz.product.feature.ParametricSearch
>>> +import org.apache.lucene.search.*
>>> +import org.apache.lucene.index.DirectoryReader
>>>   import org.apache.ofbiz.base.util.UtilProperties
>>>
>>> -
>>>   queryLine = parameters.queryLine
>>>
>>>   siteId = parameters.lcSiteId
>>> @@ -41,7 +39,7 @@ searchFeature3 = (String) parameters.SEA
>>>
>>>   featureIdByType = ParametricSearch.makeFeatureIdByTypeMap(
>>> UtilHttp.getParameterMap(request))
>>>
>>> -combQuery = new BooleanQuery.Builder()
>>> +combQuery = new BooleanQuery()
>>>
>>>   try {
>>>       DirectoryReader reader = DirectoryReader.open(FSDirectory.open(new
>>> File(SearchWorker.getIndexPath("content")).toPath()))
>>> @@ -66,7 +64,7 @@ if (queryLine || siteId) {
>>>   }
>>>
>>>   if (searchFeature1 || searchFeature2 || searchFeature3 ||
>>> !featureIdByType.isEmpty()) {
>>> -    featureQuery = new BooleanQuery.Builder()
>>> +    featureQuery = new BooleanQuery()
>>>       featuresRequired = BooleanClause.Occur.MUST
>>>       if ("any".equals(parameters.any_or_all)) {
>>>           featuresRequired = BooleanClause.Occur.SHOULD
>>> @@ -92,12 +90,12 @@ if (searchFeature1 || searchFeature2 ||
>>>               termQuery = new TermQuery(new Term("feature", value))
>>>               featureQuery.add(termQuery, featuresRequired)
>>>           }
>>> -    combQuery.add(featureQuery.build(), featuresRequired)
>>> +    combQuery.add(featureQuery, featuresRequired)
>>>       }
>>>   }
>>>   if (searcher) {
>>>       TopScoreDocCollector collector = TopScoreDocCollector.create(100)
>>> //defaulting to 100 results
>>> -    searcher.search(combQuery.build(), collector)
>>> +    searcher.search(combQuery, collector)
>>>       ScoreDoc[] hits = collector.topDocs().scoreDocs
>>>
>>>       contentList = [] as ArrayList
>>>
>>> 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=
>>> 1794770&r1=1794769&r2=1794770&view=diff
>>> ============================================================
>>> ==================
>>> --- ofbiz/ofbiz-plugins/trunk/lucene/groovyScripts/content/Searc
>>> hProducts.groovy
>>> (original)
>>> +++ ofbiz/ofbiz-plugins/trunk/lucene/groovyScripts/content/Searc
>>> hProducts.groovy
>>> Wed May 10 23:58:31 2017
>>> @@ -25,11 +25,16 @@ 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.*
>>> +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.store.FSDirectory
>>>
>>>   if (parameters.luceneQuery) {
>>> -    combQuery = new BooleanQuery.Builder()
>>> +    Query combQuery = new BooleanQuery()
>>>       IndexSearcher searcher
>>>       WhitespaceAnalyzer analyzer
>>>       try {
>>> @@ -53,7 +58,7 @@ if (parameters.luceneQuery) {
>>>       combQuery.add(query, BooleanClause.Occur.MUST)
>>>
>>>       TopScoreDocCollector collector = TopScoreDocCollector.create(100)
>>> //
>>> defaulting to 100 results
>>> -    searcher.search(combQuery.build(), collector)
>>> +    searcher.search(combQuery, collector)
>>>       ScoreDoc[] hits = collector.topDocs().scoreDocs
>>>       productList = []
>>>       hits.each { hit ->
>>>
>>> Modified: ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/
>>> apache/ofbiz/content/search/ProductDocument.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/
>>> lucene/src/main/java/org/apache/ofbiz/content/search/
>>> ProductDocument.java?rev=1794770&r1=1794769&r2=1794770&view=diff
>>> ============================================================
>>> ==================
>>> --- ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/
>>> apache/ofbiz/content/search/ProductDocument.java (original)
>>> +++ ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/
>>> apache/ofbiz/content/search/ProductDocument.java Wed May 10 23:58:31
>>> 2017
>>> @@ -87,13 +87,13 @@ public class ProductDocument implements
>>>                   this.addTextFieldByWeight(doc, "description",
>>> product.getString("description"), "index.weight.Product.description", 0,
>>> false, "fullText", delegator);
>>>                   this.addTextFieldByWeight(doc, "longDescription",
>>> product.getString("longDescription"), "index.weight.Product.longDesc
>>> ription",
>>> 0, false, "fullText", delegator);
>>>                   // OFBiz-8316, the LongPoint should be reused when
>>> updating to Solr 6.4.1 or later
>>> -                doc.add(new StringField("introductionDate",
>>> String.valueOf(quantizeTimestampToDays(product.getTimestamp(
>>> "introductionDate"))),
>>> Field.Store.NO));
>>> -//                doc.add(new LongPoint("introductionDate",
>>> quantizeTimestampToDays(product.getTimestamp("introductionDate"))));
>>> +//                doc.add(new StringField("introductionDate",
>>> String.valueOf(quantizeTimestampToDays(product.getTimestamp(
>>> "introductionDate"))),
>>> Field.Store.NO));
>>> +                doc.add(new LongPoint("introductionDate",
>>> quantizeTimestampToDays(product.getTimestamp("introductionDate"))));
>>>                   nextReIndex = this.checkSetNextReIndex(
>>> product.getTimestamp("introductionDate"), nextReIndex);
>>>                   // OFBiz-8316, the LongPoint should be reused when
>>> updating to Solr 6.4.1 or later
>>>   //                doc.add(new LongField("salesDiscontinuationDate",
>>> quantizeTimestampToDays(product.getTimestamp("salesDiscontin
>>> uationDate")),
>>> Field.Store.NO));
>>> -                doc.add(new StringField("salesDiscontinuationDate",
>>> String.valueOf(quantizeTimestampToDays(product.getTimestamp(
>>> "salesDiscontinuationDate"))),
>>> Field.Store.NO));
>>> -//                doc.add(new LongPoint("salesDiscontinuationDate",
>>> quantizeTimestampToDays(product.getTimestamp("
>>> salesDiscontinuationDate"))));
>>> +//                doc.add(new StringField("salesDiscontinuationDate",
>>> String.valueOf(quantizeTimestampToDays(product.getTimestamp(
>>> "salesDiscontinuationDate"))),
>>> Field.Store.NO));
>>> +                doc.add(new LongPoint("salesDiscontinuationDate",
>>> quantizeTimestampToDays(product.getTimestamp("
>>> salesDiscontinuationDate"))));
>>>                   nextReIndex = this.checkSetNextReIndex(
>>> product.getTimestamp("salesDiscontinuationDate"), nextReIndex);
>>>                   doc.add(new StringField("isVariant",
>>> product.get("isVariant") != null && product.getBoolean("isVariant") ?
>>> "true" : "false", Field.Store.NO));
>>>
>>> @@ -252,8 +252,8 @@ public class ProductDocument implements
>>>                       fieldNameSb.append("_price");
>>>                       // OFBiz-8316, the DoublePoint should be reused
>>> when
>>> updating to Solr 6.4.1 or later
>>>   //                    doc.add(new DoubleField(fieldNameSb.toString(),
>>> productPrice.getDouble("price"), Field.Store.NO));
>>> -                    doc.add(new StringField(fieldNameSb.toString(),
>>> String.valueOf(productPrice.getDouble("price")), Field.Store.NO));
>>> -//                    doc.add(new DoublePoint(fieldNameSb.toString(),
>>> productPrice.getDouble("price")));
>>> +//                    doc.add(new StringField(fieldNameSb.toString(),
>>> String.valueOf(productPrice.getDouble("price")), Field.Store.NO));
>>> +                    doc.add(new DoublePoint(fieldNameSb.toString(),
>>> productPrice.getDouble("price")));
>>>                   }
>>>
>>>                   // Index ProductSuppliers
>>>
>>> Modified: ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/
>>> apache/ofbiz/content/search/SearchWorker.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/
>>> lucene/src/main/java/org/apache/ofbiz/content/search/
>>> SearchWorker.java?rev=1794770&r1=1794769&r2=1794770&view=diff
>>> ============================================================
>>> ==================
>>> --- ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/
>>> apache/ofbiz/content/search/SearchWorker.java (original)
>>> +++ ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/
>>> apache/ofbiz/content/search/SearchWorker.java Wed May 10 23:58:31 2017
>>> @@ -41,7 +41,7 @@ public final class SearchWorker {
>>>
>>>       public static final String module = SearchWorker.class.getName();
>>>
>>> -    private static final Version LUCENE_VERSION = Version.LUCENE_6_2_1;
>>> +    private static final Version LUCENE_VERSION = Version.LUCENE_6_5_1;
>>>
>>>       private SearchWorker() {}
>>>
>>> @@ -68,7 +68,7 @@ public final class SearchWorker {
>>>
>>>       public static String getIndexPath(String path) {
>>>           String basePath = UtilProperties.getPropertyValue("lucene",
>>> "defaultIndex", "index");
>>> -        return (UtilValidate.isNotEmpty(path)? basePath + "/" + path:
>>> basePath);
>>> +        return (UtilValidate.isNotEmpty(path)? basePath + "/" + path +
>>> "/index" : basePath);
>>>       }
>>>
>>>       public static void indexContentList(LocalDispatcher dispatcher,
>>> Delegator delegator, List<String> idList) throws Exception {
>>>
>>>
>>>
>>>
>>
>


-- 
Renuka Srishti

Reply via email to