我正在使用Hibernate - Lucene Search。
当索引文件/表中没有可用数据时,我在排序时遇到以下运行时异常。
这是我的代码:
.......... .......... query.setFirstResult(的startIndex); query.setMaxResults(displayCount);
Sort sort = null;
SortField sortField = new SortField**("vendorName",!true);
sort = new Sort(sortField);
query.setSort(sort);
objList = query.setProjection(searchFields).setResultTransformer(objSavantAliasToBeanResultTransformer).list();
........ ........
java.lang.RuntimeException:字段vendorName中没有术语 - 无法确定排序类型 at org.apache.lucene.search.ExtendedFieldCacheImpl $ 5.createValue(ExtendedFieldCacheImpl.java:139) at org.apache.lucene.search.FieldCacheImpl $ Cache.get(FieldCacheImpl.java:71) at org.apache.lucene.search.ExtendedFieldCacheImpl.getAuto(ExtendedFieldCacheImpl.java:127) at org.apache.lucene.search.FieldSortedHitQueue.comparatorAuto(FieldSortedHitQueue.java:487) 在org.apache.lucene.search.FieldSortedHitQueue $ 1.createValue(FieldSortedHitQueue.java:184) at org.apache.lucene.search.FieldCacheImpl $ Cache.get(FieldCacheImpl.java:71) 在org.apache.lucene.search.FieldSortedHitQueue.getCachedComparator(FieldSortedHitQueue.java:167) 在org.apache.lucene.search.FieldSortedHitQueue。(FieldSortedHitQueue.java:55) 在org.apache.lucene.search.TopFieldDocCollector。(TopFieldDocCollector.java:43) 在org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:121) 在org.apache.lucene.search.Searcher.search(Searcher.java:86) 在org.hibernate.search.query.QueryHits.updateTopDocs(QueryHits.java:103) 在org.hibernate.search.query.QueryHits。(QueryHits.java:61) 在org.hibernate.search.query.FullTextQueryImpl.getQueryHits(FullTextQueryImpl.java:354) 在org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:270) at com.tis.purchasedetails.dao.PurchaseDetailsDAO.getAllPurchaseDetails(PurchaseDetailsDAO.java:1025) 在org.apache.jsp.jsp.PurchaseDetails.purchaseDetailsList_jsp._jspService(purchaseDetailsList_jsp.java:275) 在org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 在org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332) 在org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) 在org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 在org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672) 在org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463) 在org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
答案 0 :(得分:1)
您必须使用其他 SortField 构造函数。使用您指定的那个 type 。另请参阅https://issues.apache.org/jira/browse/LUCENE-1729