hibernate搜索的@Facet注释由于某种原因不起作用。它几乎就像完全忽略它甚至存在。我粘贴了下面的例外,但无论我如何配置它,它总是失败......
我认为这与值为null有关。如果索引中的值为null,则认为该值未被索引。对于数据库中的此对象,上面的upperModel的值为null ...我怀疑如果我希望在索引中的每个项目中都有值,那么它将起作用。当与Lucene 5.5.5结合使用时,这可能是hibernate搜索中的一个错误,它与Matrix兼容。
如果索引根本不包含任何值,则 org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetCounts getDim
为upperMake属性返回null ...在我的情况下,我只将一个对象编入索引以进行测试,并且它没有此facet的值...
我通过在我设置为Facet的所有字段中添加一个值来进行实验,而不再是例外。这证明了理论,但我担心如果用户获得的结果集对于单个方面都是空的,那么它将错误地搜索...
守则
@Facet
@Field(name = "upperModel", index = org.hibernate.search.annotations.Index.YES, analyze = Analyze.NO, store = Store.NO)
@Column(length = 50)
@Size(max = 50)
public String getUpperModel() {
return this.upperModel;
}
我也试过以下变种......
@Facet
private String upperModel;
@Facets({@Facet})
private String upperModel;
例外
org.hibernate.search.exception.SearchException: HSEARCH000268: Facet request 'upperModel' tries to facet on field 'upperModel' which either does not exist or is not configured for faceting (via @Facet). Check your configuration.
at org.hibernate.search.query.engine.impl.QueryHits.updateStringFacets(QueryHits.java:407)
at org.hibernate.search.query.engine.impl.QueryHits.updateFacets(QueryHits.java:259)
at org.hibernate.search.query.engine.impl.QueryHits.updateTopDocs(QueryHits.java:242)
at org.hibernate.search.query.engine.impl.QueryHits.<init>(QueryHits.java:129)
at org.hibernate.search.query.engine.impl.LuceneHSQuery.getQueryHits(LuceneHSQuery.java:361)
at org.hibernate.search.query.engine.impl.LuceneHSQuery.queryEntityInfos(LuceneHSQuery.java:150)
at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.doHibernateSearchList(FullTextQueryImpl.java:237)
at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.list(FullTextQueryImpl.java:222)
at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.getResultList(FullTextQueryImpl.java:121)
at com.jjkane.biz.services.SearchService.searchInventory(SearchService.java:846)
at com.jjkane.biz.services.SearchService$$FastClassBySpringCGLIB$$c03b900c.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:747)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)