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.dynamic.data.mapping.internal.search.DDMFormInstanceRecordIndexer.java

License:Open Source License

public DDMFormInstanceRecordIndexer() {
    setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.UID);
    setDefaultSelectedLocalizedFieldNames(Field.DESCRIPTION, Field.TITLE);
    setPermissionAware(true);//  ww  w  . j  a  v  a2  s  .  co  m
}

From source file:com.liferay.dynamic.data.mapping.internal.search.DDMFormInstanceRecordIndexer.java

License:Open Source License

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

    long ddmFormInstanceId = GetterUtil.getLong(document.get("formInstanceId"));

    String title = getTitle(ddmFormInstanceId, locale);

    Summary summary = createSummary(document, Field.TITLE, Field.DESCRIPTION);

    summary.setMaxContentLength(200);/*from w  ww  .j  a v a  2s  .  c o m*/
    summary.setTitle(title);

    return summary;
}

From source file:com.liferay.experts.questions.util.QuestionsIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    Question question = (Question) obj;/*from  w w  w. j  a v a  2 s  . c  o  m*/

    Document document = getBaseModelDocument(PORTLET_ID, question);

    document.addText(Field.CONTENT, question.getContent());
    document.addText(Field.TITLE, question.getTitle());
    document.addText("answers", getAnswers(question.getQuestionId()));

    return document;
}

From source file:com.liferay.experts.questions.util.QuestionsIndexer.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  ww .  j ava 2  s  .  c  o  m

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

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

    portletURL.setParameter("mvcPath", "/question/view_question.jsp");
    portletURL.setParameter("questionId", questionId);

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

From source file:com.liferay.exportimport.search.ExportImportConfigurationIndexer.java

License:Open Source License

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

    Summary summary = createSummary(document, Field.TITLE, Field.DESCRIPTION);

    return summary;
}

From source file:com.liferay.hook.indexer.MBMessageIndexerPostProcessor.java

License:Open Source License

@Override
public void postProcessDocument(Document document, Object object) throws Exception {

    MBMessage mbMessage = (MBMessage) object;

    Map<Locale, String> contentsMap = new HashMap<Locale, String>();
    Map<Locale, String> titleMap = new HashMap<Locale, String>();

    // Get all avilable languages of this site to create indexs for all of
    // them.// w  w  w  .  j a  v a2s.  c  om
    //
    // To get Site Language, use LocaleThreadLocal.getSiteDefaultLocale()
    // To get Display language, use
    // LocaleThreadLocal.getThemeDisplayLocale()
    Long groupId = mbMessage.getGroupId();
    Locale locales[] = LanguageUtil.getAvailableLocales(groupId);

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

    if (content.length() <= 0) {
        return;
    }

    for (int i = 0; i < locales.length; i++) {
        contentsMap.put(locales[i], content);
        titleMap.put(locales[i], title);
    }
    document.addLocalizedText(Field.TITLE, titleMap);
    document.addLocalizedText(Field.CONTENT, contentsMap);
}

From source file:com.liferay.hook.indexer.MBMessageIndexerPostProcessor.java

License:Open Source License

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

    String[] fields = { Field.CONTENT, Field.TITLE };
    addSearchTerms(searchQuery, searchContext, fields, false);

}

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

License:Open Source License

public JournalArticleIndexer() {
    setDefaultSelectedFieldNames(Field.ASSET_TAG_NAMES, Field.ARTICLE_ID, Field.COMPANY_ID,
            Field.DEFAULT_LANGUAGE_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.GROUP_ID,
            Field.MODIFIED_DATE, Field.SCOPE_GROUP_ID, Field.VERSION, Field.UID);
    setDefaultSelectedLocalizedFieldNames(Field.CONTENT, Field.DESCRIPTION, Field.TITLE);
    setFilterSearch(true);//from   w  w  w .  j a  v  a 2  s.  c  om
    setPermissionAware(true);
    setSelectAllLocales(true);
}

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

License:Open Source License

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

    addSearchTerm(searchQuery, searchContext, Field.ARTICLE_ID, false);
    addSearchTerm(searchQuery, searchContext, Field.CLASS_PK, false);
    addSearchLocalizedTerm(searchQuery, searchContext, Field.CONTENT, false);
    addSearchLocalizedTerm(searchQuery, searchContext, Field.DESCRIPTION, false);
    addSearchTerm(searchQuery, searchContext, Field.ENTRY_CLASS_PK, false);
    addSearchLocalizedTerm(searchQuery, searchContext, Field.TITLE, false);
    addSearchTerm(searchQuery, searchContext, Field.USER_NAME, false);

    LinkedHashMap<String, Object> params = (LinkedHashMap<String, Object>) searchContext.getAttribute("params");

    if (params != null) {
        String expandoAttributes = (String) params.get("expandoAttributes");

        if (Validator.isNotNull(expandoAttributes)) {
            addSearchExpando(searchQuery, searchContext, expandoAttributes);
        }/*w  w w . j  a v a2  s.  com*/
    }
}

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

License:Open Source License

@Override
protected Document doGetDocument(JournalArticle journalArticle) throws Exception {

    Document document = getBaseModelDocument(CLASS_NAME, journalArticle);

    long classPK = journalArticle.getId();

    if (!isIndexAllArticleVersions()) {
        classPK = journalArticle.getResourcePrimKey();
    }/*  w w w. java 2 s  .  c o m*/

    document.addUID(CLASS_NAME, classPK);

    String articleDefaultLanguageId = LocalizationUtil.getDefaultLanguageId(journalArticle.getDocument());

    String[] languageIds = LocalizationUtil.getAvailableLanguageIds(journalArticle.getDocument());

    for (String languageId : languageIds) {
        String content = extractDDMContent(journalArticle, languageId);

        String description = journalArticle.getDescription(languageId);

        String title = journalArticle.getTitle(languageId);

        if (languageId.equals(articleDefaultLanguageId)) {
            document.addText(Field.CONTENT, content);
            document.addText(Field.DESCRIPTION, description);
            document.addText("defaultLanguageId", languageId);
        }

        document.addText(LocalizationUtil.getLocalizedName(Field.CONTENT, languageId), content);
        document.addText(LocalizationUtil.getLocalizedName(Field.DESCRIPTION, languageId), description);
        document.addText(LocalizationUtil.getLocalizedName(Field.TITLE, languageId), title);
    }

    document.addKeyword(Field.FOLDER_ID, journalArticle.getFolderId());

    String articleId = journalArticle.getArticleId();

    if (journalArticle.isInTrash()) {
        articleId = TrashUtil.getOriginalTitle(articleId);
    }

    document.addKeywordSortable(Field.ARTICLE_ID, articleId);

    document.addKeyword(Field.LAYOUT_UUID, journalArticle.getLayoutUuid());
    document.addKeyword(Field.TREE_PATH, StringUtil.split(journalArticle.getTreePath(), CharPool.SLASH));
    document.addKeyword(Field.VERSION, journalArticle.getVersion());

    document.addKeyword("ddmStructureKey", journalArticle.getDDMStructureKey());
    document.addKeyword("ddmTemplateKey", journalArticle.getDDMTemplateKey());
    document.addDate("displayDate", journalArticle.getDisplayDate());
    document.addKeyword("head", JournalUtil.isHead(journalArticle));

    boolean headListable = JournalUtil.isHeadListable(journalArticle);

    document.addKeyword("headListable", headListable);

    // Scheduled listable articles should be visible in asset browser

    if (journalArticle.isScheduled() && headListable) {
        boolean visible = GetterUtil.getBoolean(document.get("visible"));

        if (!visible) {
            document.addKeyword("visible", true);
        }
    }

    addDDMStructureAttributes(document, journalArticle);

    return document;
}