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

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

Introduction

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

Prototype

String TITLE

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

Click Source Link

Usage

From source file:com.liferay.journal.search.JournalArticleIndexer.java

License:Open Source License

@Override
protected String doGetSortField(String orderByCol) {
    if (orderByCol.equals("display-date")) {
        return "displayDate";
    } else if (orderByCol.equals("id")) {
        return Field.ENTRY_CLASS_PK;
    } else if (orderByCol.equals("modified-date")) {
        return Field.MODIFIED_DATE;
    } else if (orderByCol.equals("title")) {
        return Field.TITLE;
    } else {/*from  w  ww  .jav  a  2  s .co  m*/
        return orderByCol;
    }
}

From source file:com.liferay.journal.search.JournalArticleIndexer.java

License:Open Source License

@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletRequest portletRequest,
        PortletResponse portletResponse) {

    Locale defaultLocale = LocaleUtil.fromLanguageId(document.get("defaultLanguageId"));

    Locale snippetLocale = getSnippetLocale(document, locale);

    String localizedTitleName = DocumentImpl.getLocalizedName(locale, Field.TITLE);

    if ((snippetLocale == null) && (document.getField(localizedTitleName) == null)) {

        snippetLocale = defaultLocale;/*from  w  w w.  j  a v a 2 s.  c o  m*/
    } else {
        snippetLocale = locale;
    }

    String title = document.get(snippetLocale, Field.SNIPPET + StringPool.UNDERLINE + Field.TITLE, Field.TITLE);

    if (Validator.isNull(title) && !snippetLocale.equals(defaultLocale)) {
        title = document.get(defaultLocale, Field.SNIPPET + StringPool.UNDERLINE + Field.TITLE, Field.TITLE);
    }

    String content = getDDMContentSummary(document, snippetLocale, portletRequest, portletResponse);

    if (Validator.isNull(content) && !snippetLocale.equals(defaultLocale)) {
        content = getDDMContentSummary(document, defaultLocale, portletRequest, portletResponse);
    }

    Summary summary = new Summary(snippetLocale, title, content);

    summary.setMaxContentLength(200);

    return summary;
}

From source file:com.liferay.journal.search.JournalFolderIndexer.java

License:Open Source License

public JournalFolderIndexer() {
    setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.DESCRIPTION, Field.ENTRY_CLASS_NAME,
            Field.ENTRY_CLASS_PK, Field.TITLE, Field.UID);
    setFilterSearch(true);// www.j a v  a  2 s.c  om
    setPermissionAware(true);
}

From source file:com.liferay.journal.search.JournalFolderIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(JournalFolder journalFolder) throws Exception {

    if (_log.isDebugEnabled()) {
        _log.debug("Indexing journalFolder " + journalFolder);
    }/*from  w ww.  j av a 2s  . com*/

    Document document = getBaseModelDocument(CLASS_NAME, journalFolder);

    document.addText(Field.DESCRIPTION, journalFolder.getDescription());
    document.addKeyword(Field.FOLDER_ID, journalFolder.getParentFolderId());

    String title = journalFolder.getName();

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

    document.addText(Field.TITLE, title);

    document.addKeyword(Field.TREE_PATH, StringUtil.split(journalFolder.getTreePath(), CharPool.SLASH));

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

    return document;
}

From source file:com.liferay.journal.search.test.JournalArticleIndexerSummaryTest.java

License:Open Source License

protected void setFields(String title, String content, Document document) {
    document.addText(getFieldName(Field.CONTENT), content);
    document.addText(getFieldName(Field.TITLE), title);
}

From source file:com.liferay.journal.search.test.JournalArticleIndexerSummaryTest.java

License:Open Source License

protected void setSnippets(String highlightedTitle, String highlightedContent, Document document) {

    document.addText(getSnippetFieldName(Field.CONTENT), highlightedContent);
    document.addText(getSnippetFieldName(Field.TITLE), highlightedTitle);
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

protected SearchContext buildSearchContext(long companyId, long groupId, List<Long> folderIds, long classNameId,
        String articleId, String title, String description, String content, int status, String ddmStructureKey,
        String ddmTemplateKey, LinkedHashMap<String, Object> params, boolean andSearch, int start, int end,
        Sort sort) {//from w  w w.  ja  v a  2s  .com

    SearchContext searchContext = new SearchContext();

    searchContext.setAndSearch(andSearch);

    Map<String, Serializable> attributes = new HashMap<>();

    attributes.put(Field.ARTICLE_ID, articleId);
    attributes.put(Field.CLASS_NAME_ID, classNameId);
    attributes.put(Field.CONTENT, content);
    attributes.put(Field.DESCRIPTION, description);
    attributes.put(Field.STATUS, status);
    attributes.put(Field.TITLE, title);
    attributes.put("ddmStructureKey", ddmStructureKey);
    attributes.put("ddmTemplateKey", ddmTemplateKey);
    attributes.put("params", params);

    searchContext.setAttributes(attributes);

    searchContext.setCompanyId(companyId);
    searchContext.setEnd(end);
    searchContext.setFolderIds(folderIds);
    searchContext.setGroupIds(new long[] { groupId });

    if (params != null) {
        searchContext.setIncludeDiscussions(GetterUtil.getBoolean(params.get("includeDiscussions")));

        String keywords = (String) params.remove("keywords");

        if (Validator.isNotNull(keywords)) {
            searchContext.setKeywords(keywords);
        }
    }

    QueryConfig queryConfig = new QueryConfig();

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

    searchContext.setQueryConfig(queryConfig);

    if (sort != null) {
        searchContext.setSorts(sort);
    }

    searchContext.setStart(start);

    return searchContext;
}

From source file:com.liferay.journal.web.internal.display.context.JournalDisplayContext.java

License:Open Source License

protected SearchContext buildSearchContext(long companyId, long groupId, List<java.lang.Long> folderIds,
        long classNameId, String ddmStructureKey, String ddmTemplateKey, String keywords,
        LinkedHashMap<String, Object> params, int start, int end, Sort sort, boolean showVersions) {

    String articleId = null;//from  ww w  .  ja  v  a  2  s .  c o m
    String title = null;
    String description = null;
    String content = null;
    boolean andOperator = false;

    if (Validator.isNotNull(keywords)) {
        articleId = keywords;
        title = keywords;
        description = keywords;
        content = keywords;
    } else {
        andOperator = true;
    }

    if (params != null) {
        params.put("keywords", keywords);
    }

    SearchContext searchContext = new SearchContext();

    searchContext.setAndSearch(andOperator);

    Map<String, Serializable> attributes = new HashMap<>();

    attributes.put(Field.ARTICLE_ID, articleId);
    attributes.put(Field.CLASS_NAME_ID, classNameId);
    attributes.put(Field.CONTENT, content);
    attributes.put(Field.DESCRIPTION, description);
    attributes.put(Field.STATUS, getStatus());
    attributes.put(Field.TITLE, title);
    attributes.put("ddmStructureKey", ddmStructureKey);
    attributes.put("ddmTemplateKey", ddmTemplateKey);
    attributes.put("params", params);

    searchContext.setAttributes(attributes);

    searchContext.setCompanyId(companyId);
    searchContext.setEnd(end);
    searchContext.setFolderIds(folderIds);
    searchContext.setGroupIds(new long[] { groupId });
    searchContext.setIncludeDiscussions(GetterUtil.getBoolean(params.get("includeDiscussions"), true));

    if (params != null) {
        keywords = (String) params.remove("keywords");

        if (Validator.isNotNull(keywords)) {
            searchContext.setKeywords(keywords);
        }
    }

    searchContext.setAttribute("head", !showVersions);
    searchContext.setAttribute("params", params);
    searchContext.setEnd(end);
    searchContext.setFolderIds(folderIds);
    searchContext.setStart(start);

    QueryConfig queryConfig = new QueryConfig();

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

    searchContext.setQueryConfig(queryConfig);

    if (sort != null) {
        searchContext.setSorts(sort);
    }

    searchContext.setStart(start);

    return searchContext;
}

From source file:com.liferay.journal.web.internal.search.JournalSearcher.java

License:Open Source License

public JournalSearcher() {
    setDefaultSelectedFieldNames(Field.ARTICLE_ID, Field.COMPANY_ID, Field.DEFAULT_LANGUAGE_ID,
            Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.GROUP_ID, Field.VERSION, Field.UID);
    setDefaultSelectedLocalizedFieldNames(Field.CONTENT, Field.DESCRIPTION, Field.TITLE);
    setFilterSearch(true);/*from  w  ww.  j  a v  a 2 s.com*/
    setPermissionAware(true);
    setSelectAllLocales(true);
}

From source file:com.liferay.knowledgebase.admin.util.AdminIndexer.java

License:Open Source License

public AdminIndexer() {
    setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.CONTENT, Field.CREATE_DATE, Field.DESCRIPTION,
            Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.MODIFIED_DATE, Field.TITLE, Field.UID,
            Field.USER_NAME);/*  w  w w  .  ja va 2  s  . com*/
    setFilterSearch(true);
    setPermissionAware(true);
}