在Liferay 6.2中,我使用了不赞成在Liferay 7.0中使用的布尔查询。我该如何更改此方法?

时间:2019-04-10 16:29:56

标签: liferay-6 liferay-7

如何在Liferay 7中更改此方法?

private static void addVimapFileEntryIdClause(SearchContext searchContext, List<BooleanClause> fieldClauses,long fileEntryIdStart, long fileEntryIdEnd, String vimapFileEntry){

 if (fileEntryIdStart != QueryUtil.ALL_POS) {

    BooleanQuery fileEntryBooleanQuery = BooleanQueryFactoryUtil.create(
                            searchContext);

        if (fileEntryIdStart == fileEntryIdEnd) {

        fileEntryBooleanQuery.addRequiredTerm( 
                   VIMAPConstants.VIMAP_FILE_ENTRY_ID, fileEntryIdStart);
    }
    else {
        fileEntryBooleanQuery.addNumericRangeTerm(
            vimapFileEntry, fileEntryIdStart, fileEntryIdEnd);
        }

    BooleanClause fileEntryFieldClause =
        BooleanClauseFactoryUtil.create(searchContext, 
                  fileEntryBooleanQuery,BooleanClauseOccur.MUST.getName());
            fieldClauses.add(fileEntryFieldClause);
 }
}

我这样改变,但效果不好

private static void addFolderIdClause(             SearchContext searchContext,List> fieldClauses,             长folderId)     {         BooleanQuery文件夹BooleanQuery = new BooleanQueryImpl();

    /*BooleanQuery folderBooleanQuery = BooleanQueryFactoryUtil.create(
                searchContext);*/
    folderBooleanQuery.addRequiredTerm(Field.FOLDER_ID, folderId);

    /*BooleanClause folderFieldClause = BooleanClauseFactoryUtil.create(
                                searchContext, folderBooleanQuery,
                                    BooleanClauseOccur.MUST.getName());*/

    BooleanClause<Query> folderFieldClause =
            BooleanClauseFactoryUtil.create(folderBooleanQuery,
                    BooleanClauseOccur.MUST.getName());

    fieldClauses.add(folderFieldClause);
}

1 个答案:

答案 0 :(得分:0)

已弃用的不是BooleanQuery,而是BooleanQueryFactoryUtil。在there中,您可以看到

 * @deprecated As of Wilberforce (7.0.x), , replaced by {@link
 *             com.liferay.portal.kernel.search.generic.BooleanQueryImpl}

已弃用的Util类的(链接)代码非常简单。 (注意:我已链接到master分支,而不是7.0-如有必要,请进行调整)