Example usage for com.liferay.portal.kernel.search Indexer getSummary

List of usage examples for com.liferay.portal.kernel.search Indexer getSummary

Introduction

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

Prototype

public Summary getSummary(Document document, String snippet, PortletRequest portletRequest,
            PortletResponse portletResponse) throws SearchException;

Source Link

Usage

From source file:com.liferay.journal.content.search.web.internal.display.context.JournalContentSearchDisplayContext.java

License:Open Source License

public Summary getSummary(Document document) throws Exception {
    if (_summary != null) {
        return _summary;
    }/*from   w w w  .j  ava 2s.c  o m*/

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    Indexer<JournalArticle> indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class);

    com.liferay.portal.kernel.search.Summary summary = indexer.getSummary(document, StringPool.BLANK,
            _liferayPortletRequest, _liferayPortletResponse);

    SummaryBuilder summaryBuilder = _summaryBuilderFactory.newInstance();

    summaryBuilder.setContent(summary.getContent());
    summaryBuilder.setHighlight(_journalContentSearchPortletInstanceConfiguration.enableHighlighting());
    summaryBuilder.setLocale(themeDisplay.getLocale());
    summaryBuilder.setMaxContentLength(summary.getMaxContentLength());
    summaryBuilder.setTitle(summary.getTitle());

    _summary = summaryBuilder.build();

    return _summary;
}