Example usage for com.liferay.portal.kernel.search SearchContext setAssetCategoryIds

List of usage examples for com.liferay.portal.kernel.search SearchContext setAssetCategoryIds

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.search SearchContext setAssetCategoryIds.

Prototype

public void setAssetCategoryIds(long[] assetCategoryIds) 

Source Link

Usage

From source file:com.liferay.portlet.asset.service.impl.AssetEntryLocalServiceImpl.java

License:Open Source License

@Override
public Hits search(long companyId, long[] groupIds, long userId, String className, String userName,
        String title, String description, String assetCategoryIds, String assetTagNames, int status,
        boolean andSearch, int start, int end) throws SystemException {
    try {//from   w  w w.j a  va2s. c o m
        SearchContext searchContext = new SearchContext();

        Facet assetEntriesFacet = new AssetEntriesFacet(searchContext);

        assetEntriesFacet.setStatic(true);

        searchContext.addFacet(assetEntriesFacet);

        Facet scopeFacet = new ScopeFacet(searchContext);

        scopeFacet.setStatic(true);

        searchContext.addFacet(scopeFacet);

        searchContext.setAndSearch(andSearch);
        searchContext.setAssetCategoryIds(StringUtil.split(assetCategoryIds, 0L));
        searchContext.setAssetTagNames(StringUtil.split(assetTagNames));
        searchContext.setAttribute(Field.DESCRIPTION, description);
        searchContext.setAttribute(Field.TITLE, title);
        searchContext.setAttribute(Field.USER_NAME, userName);
        searchContext.setAttribute("paginationType", "regular");
        searchContext.setAttribute("status", status);
        searchContext.setCompanyId(companyId);
        searchContext.setEnd(end);
        searchContext.setEntryClassNames(getClassNames(companyId, className));
        searchContext.setGroupIds(groupIds);

        QueryConfig queryConfig = new QueryConfig();

        queryConfig.setHighlightEnabled(false);
        queryConfig.setScoreEnabled(false);

        searchContext.setQueryConfig(queryConfig);

        searchContext.setStart(start);
        searchContext.setUserId(userId);

        Indexer indexer = FacetedSearcher.getInstance();

        return indexer.search(searchContext);
    } catch (Exception e) {
        throw new SystemException(e);
    }
}