使用Infinispan 6.0
您好我已经在嵌入式缓存模式下设置infinispan,我可以写入cahce。现在我正在尝试添加索引,似乎所有加载都正常但是当我尝试查询我的缓存时,我得到以下异常......
org.hibernate.hql.ParsingException:HQLLUCN000003:由于分析了属性,因此无法对com.xxx.model.MyModel类型的属性ABC应用任何查询。
我似乎无法在谷歌上找到有关此错误的信息。
Infinispan配置......
<namedCache name="XYZ">
<eviction strategy="LIRS" maxEntries="30000000" />
<indexing enabled="true" indexLocalOnly="true">
<properties>
<property name="default.directory_provider" value="ram" />
</properties>
</indexing>
</namedCache>
模型就是这个......
@Indexed
public class MyModel implements Serializable
{
private static final long serialVersionUID = -3764014970811943408L;
Integer key;
@Field
@Field
String ABC;
}
我的疑问是......
Query query = qf.from(MyModel.class)
.maxResults(20000)
.having("ABC")
.toBuilder().build();
日志输出似乎没问题
DEBUG org.infinispan.jmx.JmxUtil - Object name org.infinispan:type=Cache,name="__cluster_registry_cache__(local)",manager="DefaultCacheManager",component=Cache already registered
INFO o.i.jmx.CacheJmxRegistration - ISPN000031: MBeans were successfully registered to the platform MBean server.
DEBUG org.infinispan.CacheImpl - Started cache __cluster_registry_cache__ on null
DEBUG o.i.interceptors.InterceptorChain - Interceptor chain size: 7
DEBUG o.i.interceptors.InterceptorChain - Interceptor chain is:
>> org.infinispan.interceptors.InvocationContextInterceptor
>> org.infinispan.interceptors.CacheMgmtInterceptor
>> org.infinispan.interceptors.NotificationInterceptor
>> org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor
>> org.infinispan.query.backend.LocalQueryInterceptor
>> org.infinispan.interceptors.EntryWrappingInterceptor
>> org.infinispan.interceptors.CallInterceptor
DEBUG org.infinispan.jmx.JmxUtil - Object name org.infinispan:type=Cache,name="XYZ(local)",manager="DefaultCacheManager",component=Cache already registered
INFO o.i.jmx.CacheJmxRegistration - ISPN000031: MBeans were successfully registered to the platform MBean server.
DEBUG org.infinispan.CacheImpl - Started cache XYZ on null
然后当我尝试查询...
WARN o.h.search.impl.ConfigContext - HSEARCH000075: Configuration setting hibernate.search.lucene_version was not specified, using LUCENE_CURRENT.
DEBUG o.h.s.b.impl.lucene.WorkspaceFactory - Starting workspace for index com.xxx.model.Transaction using an exclusive index strategy
DEBUG o.h.s.e.s.DocumentBuilderIndexedEntity - Field selection in projections is set to true for entity com.xxx.model.MyModel.
org.hibernate.hql.ParsingException: HQLLUCN000003: No queries can be applied to property ABC in type com.xxx.model.MyModel since the property is analyzed.
at org.hibernate.hql.lucene.internal.ClassBasedLuceneQueryResolverDelegate.normalizeProperty(ClassBasedLuceneQueryResolverDelegate.java:218)
at org.hibernate.hql.lucene.internal.ClassBasedLuceneQueryResolverDelegate.normalizePropertyPathTerminus(ClassBasedLuceneQueryResolverDelegate.java:208)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.pathedPropertyReference(GeneratedHQLResolver.java:13086)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.propertyReferencePath(GeneratedHQLResolver.java:12917)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.valueExpressionPrimary(GeneratedHQLResolver.java:7950)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.valueExpression(GeneratedHQLResolver.java:7483)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.rowValueConstructor(GeneratedHQLResolver.java:6377)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.predicate(GeneratedHQLResolver.java:5213)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.searchCondition(GeneratedHQLResolver.java:4858)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.searchCondition(GeneratedHQLResolver.java:4746)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.searchCondition(GeneratedHQLResolver.java:4746)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.searchCondition(GeneratedHQLResolver.java:4746)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.searchCondition(GeneratedHQLResolver.java:4746)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.searchCondition(GeneratedHQLResolver.java:4746)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.searchCondition(GeneratedHQLResolver.java:4746)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.whereClause(GeneratedHQLResolver.java:2348)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.querySpec(GeneratedHQLResolver.java:2203)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.queryExpression(GeneratedHQLResolver.java:2106)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.queryStatement(GeneratedHQLResolver.java:1745)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.queryStatementSet(GeneratedHQLResolver.java:1658)
at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.statement(GeneratedHQLResolver.java:654)
at org.hibernate.hql.ast.spi.QueryResolverProcessor.process(QueryResolverProcessor.java:52)
at org.hibernate.hql.QueryParser.parseQuery(QueryParser.java:82)
at org.infinispan.query.dsl.embedded.impl.EmbeddedLuceneQueryBuilder.build(EmbeddedLuceneQueryBuilder.java:51)
at org.infinispan.query.dsl.embedded.impl.EmbeddedLuceneQueryBuilder.build(EmbeddedLuceneQueryBuilder.java:27)
at com.xxx.vertx.Inifini.handle(Inifini.java:97)
at com.xxx.vertx.Inifini.handle(Inifini.java:1)
at org.vertx.java.core.eventbus.impl.DefaultEventBus$11.run(DefaultEventBus.java:929)
at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:176)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Thread.java:722)
答案 0 :(得分:2)
正如错误消息所暗示的那样,对于此类查询,您需要一个未分析的字段。 你可以通过改变模型来获得它:
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Analyze;
@Field(analyze = Analyze.NO)
String ABC;
请注意,如果您需要将此字段分析 - 因为它是其他更高级查询的要求 - 您可以使用复数形式的注释 @Fields 列出具有不同选项的多个字段