休眠搜索Lucene搜索异常

时间:2019-02-21 11:06:37

标签: hibernate lucene

为什么我们不在FullTextQuery中设置条件?

我正在查询Lucene搜索以获取具有以下条件的对象。

        ProjectionList proj = Projections.projectionList();
        proj.add( Projections.max( "composedId.versionId" ) );
        proj.add( Projections.groupProperty( "composedId.id" ) );

        DetachedCriteria detachedCriteria = DetachedCriteria.forClass( ABC.class );
        detachedCriteria.setProjection( proj );
        Criteria subQuery = fullTextSession.createCriteria( ABC.class ).add( Restrictions.eq( "isDelete", false ) )
                .add( Subqueries.propertiesIn( new String[] { "composedId.versionId", "composedId.id" }, detachedCriteria ) );
        org.hibernate.search.FullTextQuery hibQuery = fullTextSession.createFullTextQuery( parse, clazz );
        hibQuery.setCriteriaQuery( subQuery );
        Long.valueOf( hibQuery.getResultSize() )

这就是SearchException,即

       Cannot mix criteria and multiple entity types

                 System Class   ::  de.isko.software.simuspace.suscore.search.service.rest.impl.SearchServiceImpl

                 Class      ::  org.hibernate.search.query.hibernate.impl.ObjectLoaderBuilder
                 Method     ::   getCriteriaLoader
                 Exception  ::  org.hibernate.search.exception.SearchExceptionorg.hibernate.search.exception.SearchException: Cannot mix criteria and multiple entity types
at org.hibernate.search.query.hibernate.impl.ObjectLoaderBuilder.getCriteriaLoader(ObjectLoaderBuilder.java:90)
at org.hibernate.search.query.hibernate.impl.ObjectLoaderBuilder.buildLoader(ObjectLoaderBuilder.java:64)
at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.getLoader(FullTextQueryImpl.java:176)
at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.doGetResultSize(FullTextQueryImpl.java:268)
at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.getResultSize(FullTextQueryImpl.java:260)

虽然clazz是ABC类所有已索引的子实体的列表。 我在做什么错了?

0 个答案:

没有答案