2017-04-12 58 views
0

我正在嘗試搜索給定時間範圍之間的MSRP資源。我正在嘗試使用timeConstraint。 (確信有該時間範圍之間的條目)AEM 6.2- MongoDB:給定時間範圍之間的MSRP搜索結果

final Constraint timeConstraint = new RangeConstraint<Long>("timestamp_tl", until, cal.getTimeInMillis(), true); 

「直到」以上是在毫秒時間()時間小於cal.getTimeInMillis。將上面的timeConstraint添加到:

final ConstraintGroup mainConstraintGroup = new ConstraintGroup(Operator.And); 

我向MongoDB中添加了具有附加屬性「timestamp_tl」的條目。早些時候,我試着用「時間戳」。

在這兩種情況下,我得到的錯誤 -

07.04.2017 17:08:00.100 *ERROR* [sling-default-4727-com.mycomp.proj.core.services.Mysearch.12850] com.mycomp.proj.core.services.MySearchTest Task failed! 
java.lang.UnsupportedOperationException: Decimal searches not supported yet 
     at com.adobe.cq.social.sc.lucene.LuceneQueryFactory.getValueStringSolr(LuceneQueryFactory.java:554) 
     at com.adobe.cq.social.sc.lucene.LuceneQueryFactory.getValueString(LuceneQueryFactory.java:542) 
     at com.adobe.cq.social.sc.lucene.LuceneQueryFactory.getPropertyValueQuery(LuceneQueryFactory.java:511) 
     at com.adobe.cq.social.sc.lucene.LuceneQueryFactory.getComparisonQuery(LuceneQueryFactory.java:487) 
     at com.adobe.cq.social.sc.lucene.LuceneQueryFactory.mapConstraintToQueryAndFilter(LuceneQueryFactory.java:316) 
     at com.adobe.cq.social.sc.lucene.LuceneQueryFactory.mapConstraintToQueryAndFilter(LuceneQueryFactory.java:281) 
     at com.adobe.cq.social.sc.lucene.LuceneQueryFactory.mapConstraintToQueryAndFilter(LuceneQueryFactory.java:282) 
     at com.adobe.cq.social.sc.lucene.LuceneQueryFactory.getStatement(LuceneQueryFactory.java:164) 
     at com.adobe.cq.social.sc.lucene.QueryObjectModelImpl.getSelectorStatement(QueryObjectModelImpl.java:168) 
     at com.adobe.cq.social.sc.lucene.QueryObjectModelImpl.getStatement(QueryObjectModelImpl.java:109) 
     at com.adobe.cq.social.ugc.impl.LuceneUgcSearch.findCloudResources(LuceneUgcSearch.java:959) 
     at com.adobe.cq.social.ugc.impl.LuceneUgcSearch.find(LuceneUgcSearch.java:805) 
     at com.adobe.cq.social.ugc.impl.LuceneUgcSearch.find(LuceneUgcSearch.java:719) 
     at org.apache.sling.commons.scheduler.impl.QuartzJobExecutor.execute(QuartzJobExecutor.java:118) 
     at org.quartz.core.JobRunShell.run(JobRunShell.java:202) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
     at java.lang.Thread.run(Unknown Source) 

什麼我可能是做錯了什麼建議?

感謝

回答

0

我發現我需要使用

final Constraint timeConstraint = new RangeConstraint<Date>("timestamp", until, cal.getTime(), true); 

上面的 '直到' 和 'cal.getTime()' 是java.util.Date對象。我假設在MongoDB中保存的「時間戳」值是「long」值,因爲它顯示爲"NumberLong("1492006094509")"