Hibernate Search 和 Lucene:无法确定排序类型
我正在使用 Hibernate - Lucene 搜索。
当索引文件/表中没有可用数据时,我在排序时出现以下运行时异常。
这是我的代码:
......... ………… 查询.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:字段供应商名称中没有术语 - 无法确定排序类型 在 org.apache.lucene.search.ExtendedFieldCacheImpl$5.createValue(ExtendedFieldCacheImpl.java:139) 在 org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:71) 在 org.apache.lucene.search.ExtendedFieldCacheImpl.getAuto(ExtendedFieldCacheImpl.java:127) 在 org.apache.lucene.search.FieldSortedHitQueue.comparatorAuto(FieldSortedHitQueue.java:487) 在 org.apache.lucene.search.FieldSortedHitQueue$1.createValue(FieldSortedHitQueue.java:184) 在 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) 在 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)
I am using Hibernate - Lucene Search.
I have the following Runtime Exception while sorting when no data available in index file/table.
This is my code:
..........
..........
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: no terms in field vendorName - cannot determine sort type
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)
at org.apache.lucene.search.FieldSortedHitQueue$1.createValue(FieldSortedHitQueue.java:184)
at org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:71)
at org.apache.lucene.search.FieldSortedHitQueue.getCachedComparator(FieldSortedHitQueue.java:167)
at org.apache.lucene.search.FieldSortedHitQueue.(FieldSortedHitQueue.java:55)
at org.apache.lucene.search.TopFieldDocCollector.(TopFieldDocCollector.java:43)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:121)
at org.apache.lucene.search.Searcher.search(Searcher.java:86)
at org.hibernate.search.query.QueryHits.updateTopDocs(QueryHits.java:103)
at org.hibernate.search.query.QueryHits.(QueryHits.java:61)
at org.hibernate.search.query.FullTextQueryImpl.getQueryHits(FullTextQueryImpl.java:354)
at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:270)
at com.tis.purchasedetails.dao.PurchaseDetailsDAO.getAllPurchaseDetails(PurchaseDetailsDAO.java:1025)
at org.apache.jsp.jsp.PurchaseDetails.purchaseDetailsList_jsp._jspService(purchaseDetailsList_jsp.java:275)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用不同的 SortField 构造函数。 使用同时指定类型的类型。 另请参阅 https://issues.apache.org/jira/browse/LUCENE-1729< /a>
You have to use a different SortField constructor. Use the one where you specify also the type. See also https://issues.apache.org/jira/browse/LUCENE-1729