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

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

Introduction

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

Prototype

String CONTENT

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

Click Source Link

Usage

From source file:com.liferay.portlet.messageboards.util.MBIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    MBMessage message = (MBMessage) obj;

    Document document = getBaseModelDocument(PORTLET_ID, message);

    document.addKeyword(Field.CATEGORY_ID, message.getCategoryId());
    document.addText(Field.CONTENT, processContent(message));
    document.addKeyword(Field.ROOT_ENTRY_CLASS_PK, message.getRootMessageId());
    document.addText(Field.TITLE, message.getSubject());

    if (message.isAnonymous()) {
        document.remove(Field.USER_NAME);
    }// ww  w . java 2 s.  c om

    try {
        MBDiscussionLocalServiceUtil.getThreadDiscussion(message.getThreadId());

        document.addKeyword("discussion", true);
    } catch (NoSuchDiscussionException nsde) {
        document.addKeyword("discussion", false);
    }

    document.addKeyword("threadId", message.getThreadId());

    return document;
}

From source file:com.liferay.portlet.messageboards.util.MBIndexer.java

License:Open Source License

@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) {

    String title = document.get(Field.TITLE);

    String content = snippet;/*from  ww w .  j  a  v  a 2  s.c om*/

    if (Validator.isNull(snippet)) {
        content = StringUtil.shorten(document.get(Field.CONTENT), 200);
    }

    String messageId = document.get(Field.ENTRY_CLASS_PK);

    portletURL.setParameter("struts_action", "/message_boards/view_message");
    portletURL.setParameter("messageId", messageId);

    return new Summary(title, content, portletURL);
}

From source file:com.liferay.portlet.softwarecatalog.util.SCIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    SCProductEntry productEntry = (SCProductEntry) obj;

    Document document = getBaseModelDocument(PORTLET_ID, productEntry);

    StringBundler sb = new StringBundler(15);

    String longDescription = HtmlUtil.extractText(productEntry.getLongDescription());

    sb.append(longDescription);/*w w w  .  j  a  v a 2  s  .  c  o m*/

    sb.append(StringPool.SPACE);
    sb.append(productEntry.getPageURL());
    sb.append(StringPool.SPACE);
    sb.append(productEntry.getRepoArtifactId());
    sb.append(StringPool.SPACE);
    sb.append(productEntry.getRepoGroupId());
    sb.append(StringPool.SPACE);

    String shortDescription = HtmlUtil.extractText(productEntry.getShortDescription());

    sb.append(shortDescription);

    sb.append(StringPool.SPACE);
    sb.append(productEntry.getType());
    sb.append(StringPool.SPACE);
    sb.append(productEntry.getUserId());
    sb.append(StringPool.SPACE);

    String userName = PortalUtil.getUserName(productEntry.getUserId(), productEntry.getUserName());

    sb.append(userName);

    document.addText(Field.CONTENT, sb.toString());

    document.addText(Field.TITLE, productEntry.getName());
    document.addKeyword(Field.TYPE, productEntry.getType());

    String version = StringPool.BLANK;

    SCProductVersion latestProductVersion = productEntry.getLatestVersion();

    if (latestProductVersion != null) {
        version = latestProductVersion.getVersion();
    }

    document.addKeyword(Field.VERSION, version);

    document.addText("longDescription", longDescription);
    document.addText("pageURL", productEntry.getPageURL());
    document.addKeyword("repoArtifactId", productEntry.getRepoArtifactId());
    document.addKeyword("repoGroupId", productEntry.getRepoGroupId());
    document.addText("shortDescription", shortDescription);

    return document;
}

From source file:com.liferay.portlet.softwarecatalog.util.SCIndexer.java

License:Open Source License

@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) {

    String title = document.get(Field.TITLE);

    String content = snippet;//from  ww w  .  ja v  a2 s .  c o  m

    if (Validator.isNull(snippet)) {
        content = StringUtil.shorten(document.get(Field.CONTENT), 200);
    }

    String productEntryId = document.get(Field.ENTRY_CLASS_PK);

    portletURL.setParameter("struts_action", "/software_catalog/view_product_entry");
    portletURL.setParameter("productEntryId", productEntryId);

    return new Summary(title, content, portletURL);
}

From source file:com.liferay.portlet.tags.service.impl.TagsAssetLocalServiceImpl.java

License:Open Source License

public Hits search(long companyId, String portletId, String keywords, int start, int end)
        throws SystemException {

    try {//from   w w w  .ja  v  a 2  s .  c o  m
        BooleanQuery contextQuery = BooleanQueryFactoryUtil.create();

        if (Validator.isNotNull(portletId)) {
            contextQuery.addRequiredTerm(Field.PORTLET_ID, portletId);
        } else {
            BooleanQuery portletIdsQuery = BooleanQueryFactoryUtil.create();

            for (String assetTypePortletId : TagsUtil.ASSET_TYPE_PORTLET_IDS) {

                TermQuery termQuery = TermQueryFactoryUtil.create(Field.PORTLET_ID, assetTypePortletId);

                portletIdsQuery.add(termQuery, BooleanClauseOccur.SHOULD);
            }

            contextQuery.add(portletIdsQuery, BooleanClauseOccur.MUST);
        }

        BooleanQuery searchQuery = BooleanQueryFactoryUtil.create();

        if (Validator.isNotNull(keywords)) {
            searchQuery.addTerm(Field.TITLE, keywords);
            searchQuery.addTerm(Field.CONTENT, keywords);
            searchQuery.addTerm(Field.DESCRIPTION, keywords);
            searchQuery.addTerm(Field.PROPERTIES, keywords);
            searchQuery.addTerm(Field.TAGS_ENTRIES, keywords);
        }

        BooleanQuery fullQuery = BooleanQueryFactoryUtil.create();

        fullQuery.add(contextQuery, BooleanClauseOccur.MUST);

        if (searchQuery.clauses().size() > 0) {
            fullQuery.add(searchQuery, BooleanClauseOccur.MUST);
        }

        return SearchEngineUtil.search(companyId, fullQuery, start, end);
    } catch (Exception e) {
        throw new SystemException(e);
    }
}

From source file:com.liferay.portlet.wiki.util.WikiIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    WikiPage page = (WikiPage) obj;/*from   w  w w. ja v  a2 s. c  o  m*/

    Document document = getBaseModelDocument(PORTLET_ID, page);

    document.addUID(PORTLET_ID, page.getNodeId(), page.getTitle());

    String content = HtmlUtil.extractText(WikiUtil.convert(page, null, null, null));

    document.addText(Field.CONTENT, content);

    document.addKeyword(Field.NODE_ID, page.getNodeId());
    document.addText(Field.TITLE, page.getTitle());

    return document;
}

From source file:com.liferay.portlet.wiki.util.WikiIndexer.java

License:Open Source License

@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) {

    String title = document.get(Field.TITLE);

    String content = snippet;/* w w  w .  j ava2 s. co  m*/

    if (Validator.isNull(snippet)) {
        content = StringUtil.shorten(document.get(Field.CONTENT), 200);
    }

    String nodeId = document.get("nodeId");

    portletURL.setParameter("struts_action", "/wiki/view");
    portletURL.setParameter("nodeId", nodeId);
    portletURL.setParameter("title", title);

    return new Summary(title, content, portletURL);
}

From source file:com.liferay.trash.internal.search.TrashIndexer.java

License:Open Source License

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

    if (searchContext.getAttributes() == null) {
        return;/*from   w w  w. j  a  v  a2 s  . co m*/
    }

    addSearchLocalizedTerm(searchQuery, searchContext, Field.CONTENT, true);
    addSearchLocalizedTerm(searchQuery, searchContext, Field.DESCRIPTION, true);
    addSearchTerm(searchQuery, searchContext, Field.REMOVED_BY_USER_NAME, true);
    addSearchLocalizedTerm(searchQuery, searchContext, Field.TITLE, true);
    addSearchTerm(searchQuery, searchContext, Field.TYPE, false);
    addSearchTerm(searchQuery, searchContext, Field.USER_NAME, true);
}

From source file:com.liferay.wiki.search.WikiPageIndexer.java

License:Open Source License

public WikiPageIndexer() {
    setDefaultSelectedFieldNames(Field.ASSET_TAG_NAMES, Field.COMPANY_ID, Field.CONTENT, Field.ENTRY_CLASS_NAME,
            Field.ENTRY_CLASS_PK, Field.GROUP_ID, Field.MODIFIED_DATE, Field.SCOPE_GROUP_ID, Field.TITLE,
            Field.UID);//w  w  w .j ava2s.  c om
    setFilterSearch(true);
    setPermissionAware(true);
}

From source file:com.liferay.wiki.search.WikiPageIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(WikiPage wikiPage) throws Exception {
    Document document = getBaseModelDocument(CLASS_NAME, wikiPage);

    try {/*from  www . j ava 2 s  .co  m*/
        String content = HtmlUtil.extractText(_wikiEngineRenderer.convert(wikiPage, null, null, null));

        document.addText(Field.CONTENT, content);
    } catch (WikiFormatException wfe) {
        if (_log.isDebugEnabled()) {
            _log.debug("Unable to get wiki engine for " + wikiPage.getFormat());
        }
    }

    document.addKeyword(Field.NODE_ID, wikiPage.getNodeId());

    String title = wikiPage.getTitle();

    if (wikiPage.isInTrash()) {
        title = TrashUtil.getOriginalTitle(title);
    }

    document.addText(Field.TITLE, title);

    return document;
}