Example usage for com.liferay.portal.kernel.search Field ASSET_CATEGORY_TITLE

List of usage examples for com.liferay.portal.kernel.search Field ASSET_CATEGORY_TITLE

Introduction

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

Prototype

String ASSET_CATEGORY_TITLE

To view the source code for com.liferay.portal.kernel.search Field ASSET_CATEGORY_TITLE.

Click Source Link

Usage

From source file:com.liferay.asset.categories.internal.search.AssetCategoryIndexer.java

License:Open Source License

@Override
public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter,
        SearchContext searchContext) throws Exception {

    String title = (String) searchContext.getAttribute(Field.TITLE);

    if (Validator.isNotNull(title)) {
        BooleanQuery localizedQuery = new BooleanQueryImpl();

        searchContext.setAttribute(Field.ASSET_CATEGORY_TITLE, title);

        addSearchLocalizedTerm(localizedQuery, searchContext, Field.ASSET_CATEGORY_TITLE, true);
        addSearchLocalizedTerm(localizedQuery, searchContext, Field.TITLE, true);

        searchQuery.add(localizedQuery, BooleanClauseOccur.SHOULD);
    }/*  www . j a va  2s . com*/
}

From source file:com.liferay.asset.categories.internal.search.AssetCategoryIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(AssetCategory assetCategory) throws Exception {

    if (_log.isDebugEnabled()) {
        _log.debug("Indexing asset category " + assetCategory);
    }//from w  w  w. j a va 2 s  .  c o m

    Document document = getBaseModelDocument(CLASS_NAME, assetCategory);

    document.addKeyword(Field.ASSET_CATEGORY_ID, assetCategory.getCategoryId());

    List<AssetCategory> categories = new ArrayList<>(1);

    categories.add(assetCategory);

    addSearchAssetCategoryTitles(document, Field.ASSET_CATEGORY_TITLE, categories);

    document.addKeyword(Field.ASSET_PARENT_CATEGORY_ID, assetCategory.getParentCategoryId());
    document.addKeyword(Field.ASSET_VOCABULARY_ID, assetCategory.getVocabularyId());

    Locale siteDefaultLocale = _portal.getSiteDefaultLocale(assetCategory.getGroupId());

    addLocalizedField(document, Field.DESCRIPTION, siteDefaultLocale, assetCategory.getDescriptionMap());

    document.addText(Field.NAME, assetCategory.getName());
    addLocalizedField(document, Field.TITLE, siteDefaultLocale, assetCategory.getTitleMap());
    document.addKeyword("leftCategoryId", assetCategory.getLeftCategoryId());

    if (_log.isDebugEnabled()) {
        _log.debug("Document " + assetCategory + " indexed successfully");
    }

    return document;
}