List of usage examples for com.liferay.portal.kernel.search Field TITLE
String TITLE
To view the source code for com.liferay.portal.kernel.search Field TITLE.
Click Source Link
From source file:com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
public Hits search(long companyId, long groupId, long classNameId, String articleId, String title, String description, String content, String type, String status, String structureId, String templateId, LinkedHashMap<String, Object> params, boolean andSearch, int start, int end, Sort sort) throws SystemException { try {/*from ww w. j av a2 s. c o m*/ Map<String, Serializable> attributes = new HashMap<String, Serializable>(); 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(Field.TYPE, type); attributes.put("articleId", articleId); attributes.put("params", params); attributes.put("structureId", structureId); attributes.put("templateId", templateId); SearchContext searchContext = new SearchContext(); searchContext.setAndSearch(andSearch); searchContext.setAttributes(attributes); searchContext.setCompanyId(companyId); searchContext.setGroupIds(new long[] { groupId }); searchContext.setEnd(end); String keywords = (String) params.remove("keywords"); if (Validator.isNotNull(keywords)) { searchContext.setKeywords(keywords); } searchContext.setSorts(new Sort[] { sort }); QueryConfig queryConfig = new QueryConfig(); queryConfig.setHighlightEnabled(false); queryConfig.setScoreEnabled(false); searchContext.setQueryConfig(queryConfig); searchContext.setStart(start); Indexer indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class); return indexer.search(searchContext); } catch (Exception e) { throw new SystemException(e); } }
From source file:com.liferay.portlet.journal.util.JournalArticleIndexer.java
License:Open Source License
@Override public void postProcessSearchQuery(BooleanQuery searchQuery, SearchContext searchContext) throws Exception { 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.TYPE, false); // addSearchTerm(searchQuery, searchContext, Field.USER_NAME, false); addSearchTerm(searchQuery, searchContext, "articleId", 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); }//from w w w. j a v a 2 s .c om } }
From source file:com.liferay.portlet.journal.util.JournalArticleIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { JournalArticle article = (JournalArticle) obj; Document document = getBaseModelDocument(PORTLET_ID, article); long classPK = article.getId(); if (!PropsValues.JOURNAL_ARTICLE_INDEX_ALL_VERSIONS) { classPK = article.getResourcePrimKey(); }// w w w . j av a 2s . co m document.addUID(PORTLET_ID, classPK); String articleDefaultLanguageId = LocalizationUtil.getDefaultLanguageId(article.getContent()); Locale defaultLocale = LocaleUtil.getSiteDefault(); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); String[] languageIds = getLanguageIds(defaultLanguageId, article.getContent()); for (String languageId : languageIds) { String content = extractContent(article, languageId); String description = article.getDescription(languageId); String title = article.getTitle(languageId); if (languageId.equals(articleDefaultLanguageId)) { document.addText(Field.CONTENT, content); document.addText(Field.DESCRIPTION, description); document.addText(Field.TITLE, title); document.addText("defaultLanguageId", languageId); } document.addText(Field.CONTENT.concat(StringPool.UNDERLINE).concat(languageId), content); document.addText(Field.DESCRIPTION.concat(StringPool.UNDERLINE).concat(languageId), description); document.addText(Field.TITLE.concat(StringPool.UNDERLINE).concat(languageId), title); } document.addKeyword(Field.FOLDER_ID, article.getFolderId()); document.addKeyword(Field.LAYOUT_UUID, article.getLayoutUuid()); document.addKeyword(Field.TREE_PATH, StringUtil.split(article.getTreePath(), CharPool.SLASH)); document.addKeyword(Field.TYPE, article.getType()); document.addKeyword(Field.VERSION, article.getVersion()); String articleId = article.getArticleId(); if (article.isInTrash()) { articleId = TrashUtil.getOriginalTitle(articleId); } document.addKeyword("articleId", articleId); document.addKeyword("ddmStructureKey", article.getStructureId()); document.addKeyword("ddmTemplateKey", article.getTemplateId()); document.addDate("displayDate", article.getDisplayDate()); addDDMStructureAttributes(document, article); addStatusHeads(document, article); return document; }
From source file:com.liferay.portlet.journal.util.JournalArticleIndexer.java
License:Open Source License
@Override protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) { Locale snippetLocale = getSnippetLocale(document, locale); String localizedTitleName = DocumentImpl.getLocalizedName(locale, Field.TITLE); if ((snippetLocale == null) || (document.getField(localizedTitleName) == null)) { snippetLocale = LocaleUtil.fromLanguageId(document.get("defaultLanguageId")); }/*from www . j a v a 2 s . c o m*/ String title = document.get(snippetLocale, Field.SNIPPET + StringPool.UNDERLINE + Field.TITLE, Field.TITLE); String content = StringPool.BLANK; String ddmStructureKey = document.get("ddmStructureKey"); if (Validator.isNotNull(ddmStructureKey)) { content = getDDMContentSummary(document, snippetLocale); } else { content = getBasicContentSummary(document, snippetLocale); } String groupId = document.get(Field.GROUP_ID); String articleId = document.get("articleId"); String version = document.get(Field.VERSION); portletURL.setParameter("struts_action", "/journal/edit_article"); portletURL.setParameter("groupId", groupId); portletURL.setParameter("articleId", articleId); portletURL.setParameter("version", version); return new Summary(snippetLocale, title, content, portletURL); }
From source file:com.liferay.portlet.journal.util.JournalIndexer.java
License:Open Source License
@Override public void postProcessSearchQuery(BooleanQuery searchQuery, SearchContext searchContext) throws Exception { addSearchTerm(searchQuery, searchContext, Field.CLASS_PK, false); addLocalizedSearchTerm(searchQuery, searchContext, Field.CONTENT, false); addLocalizedSearchTerm(searchQuery, searchContext, Field.DESCRIPTION, false); addSearchTerm(searchQuery, searchContext, Field.ENTRY_CLASS_PK, false); addLocalizedSearchTerm(searchQuery, searchContext, Field.TITLE, false); addSearchTerm(searchQuery, searchContext, Field.TYPE, 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); }/*from ww w .ja v a2 s.c o m*/ } }
From source file:com.liferay.portlet.journal.util.JournalIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { JournalArticle article = (JournalArticle) obj; Document document = getBaseModelDocument(PORTLET_ID, article); document.addUID(PORTLET_ID, article.getGroupId(), article.getArticleId()); Locale defaultLocale = LocaleUtil.getDefault(); String defaultLangaugeId = LocaleUtil.toLanguageId(defaultLocale); String[] languageIds = getLanguageIds(defaultLangaugeId, article.getContent()); for (String languageId : languageIds) { String content = extractContent(article.getContentByLocale(languageId)); if (languageId.equals(defaultLangaugeId)) { document.addText(Field.CONTENT, content); }//from ww w . ja v a2 s.co m document.addText(Field.CONTENT.concat(StringPool.UNDERLINE).concat(languageId), content); } document.addLocalizedText(Field.DESCRIPTION, article.getDescriptionMap()); document.addLocalizedText(Field.TITLE, article.getTitleMap()); document.addKeyword(Field.TYPE, article.getType()); document.addKeyword(Field.VERSION, article.getVersion()); document.addKeyword("articleId", article.getArticleId()); document.addDate("displayDate", article.getDisplayDate()); document.addKeyword("layoutUuid", article.getLayoutUuid()); document.addKeyword("structureId", article.getStructureId()); document.addKeyword("templateId", article.getTemplateId()); JournalStructure structure = null; if (Validator.isNotNull(article.getStructureId())) { try { structure = JournalStructureLocalServiceUtil.getStructure(article.getGroupId(), article.getStructureId()); } catch (NoSuchStructureException nsse1) { Group group = GroupLocalServiceUtil.getCompanyGroup(article.getCompanyId()); try { structure = JournalStructureLocalServiceUtil.getStructure(group.getGroupId(), article.getStructureId()); } catch (NoSuchStructureException nsse2) { } } } processStructure(structure, document, article.getContent()); return document; }
From source file:com.liferay.portlet.journal.util.JournalIndexer.java
License:Open Source License
@Override protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) { String title = document.get(locale, Field.TITLE); String content = snippet;/*from ww w . j a v a 2 s . c o m*/ if (Validator.isNull(snippet)) { content = StringUtil.shorten(document.get(locale, Field.CONTENT), 200); } String groupId = document.get(Field.GROUP_ID); String articleId = document.get("articleId"); String version = document.get(Field.VERSION); portletURL.setParameter("struts_action", "/journal/edit_article"); portletURL.setParameter("groupId", groupId); portletURL.setParameter("articleId", articleId); portletURL.setParameter("version", version); return new Summary(title, content, portletURL); }
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); }//w w w . jav a 2 s . com 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;/* w w w.j ava 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);//ww w.j a va 2 s . co 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; }