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

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

Introduction

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

Prototype

public void setClassTypeIds(long[] classTypeIds) 

Source Link

Usage

From source file:com.liferay.asset.internal.util.AssetHelperImpl.java

License:Open Source License

private AssetSearcher _getAssetSearcher(SearchContext searchContext, AssetEntryQuery assetEntryQuery, int start,
        int end) throws Exception {

    Indexer<?> searcher = AssetSearcher.getInstance();

    AssetSearcher assetSearcher = (AssetSearcher) searcher;

    assetSearcher.setAssetEntryQuery(assetEntryQuery);

    Layout layout = assetEntryQuery.getLayout();

    if (layout != null) {
        searchContext.setAttribute(Field.LAYOUT_UUID, layout.getUuid());
    }/* w w  w  . jav  a 2  s .com*/

    String ddmStructureFieldName = (String) assetEntryQuery.getAttribute("ddmStructureFieldName");
    Serializable ddmStructureFieldValue = assetEntryQuery.getAttribute("ddmStructureFieldValue");

    if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) {

        searchContext.setAttribute("ddmStructureFieldName", ddmStructureFieldName);
        searchContext.setAttribute("ddmStructureFieldValue", ddmStructureFieldValue);
    }

    String paginationType = GetterUtil.getString(assetEntryQuery.getPaginationType(), "more");

    if (!paginationType.equals("none") && !paginationType.equals("simple")) {

        searchContext.setAttribute("paginationType", paginationType);
    }

    searchContext.setClassTypeIds(assetEntryQuery.getClassTypeIds());
    searchContext.setEnd(end);
    searchContext.setGroupIds(assetEntryQuery.getGroupIds());

    if (Validator.isNull(assetEntryQuery.getKeywords())) {
        QueryConfig queryConfig = searchContext.getQueryConfig();

        queryConfig.setScoreEnabled(false);
    } else {
        searchContext.setLike(true);
    }

    searchContext.setSorts(_getSorts(assetEntryQuery, searchContext.getLocale()));
    searchContext.setStart(start);

    return assetSearcher;
}