List of usage examples for com.liferay.portal.kernel.search Field DESCRIPTION
String DESCRIPTION
To view the source code for com.liferay.portal.kernel.search Field DESCRIPTION.
Click Source Link
From source file:com.liferay.portlet.documentlibrary.util.DLFolderIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { DLFolder dlFolder = (DLFolder) obj;// ww w.j a va 2 s . co m _log.info("COGNIZANT@@@@doGetDocument@@@@@DLFolderIndexer:::::Folder Id::::" + dlFolder.getFolderId() + "Folder Name:::::" + dlFolder.getName()); if (_log.isDebugEnabled()) { _log.debug("Indexing folder " + dlFolder); } Document document = null; try { document = getBaseModelDocument(PORTLET_ID, dlFolder); document.addText(Field.DESCRIPTION, dlFolder.getDescription()); document.addKeyword(Field.FOLDER_ID, dlFolder.getParentFolderId()); document.addKeyword(Field.HIDDEN, (dlFolder.isHidden() || dlFolder.isInHiddenFolder())); document.addText(Field.TITLE, dlFolder.getName()); document.addKeyword(Field.TREE_PATH, dlFolder.getTreePath()); document.addKeyword(Field.TREE_PATH, StringUtil.split(dlFolder.getTreePath(), CharPool.SLASH)); _log.info("Document " + dlFolder + " indexed successfully"); if (_log.isDebugEnabled()) { _log.debug("Document " + dlFolder + " indexed successfully"); } } catch (Exception e) { _log.error(" >>>>>> Exception in DLFolderIndexer.doGetDocument() for " + dlFolder.getFolderId(), e); folderLog.error("Folder Id " + dlFolder.getFolderId()); try { fileWriter = generateCsvFile(dlFolder.getFolderId(), fileCsvpath); } catch (IOException e1) { _log.error("Error Generating CSV", e1); } } return document; }
From source file:com.liferay.portlet.documentlibrary.util.DLFolderIndexer.java
License:Open Source License
@Override protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) { LiferayPortletURL liferayPortletURL = (LiferayPortletURL) portletURL; liferayPortletURL.setLifecycle(PortletRequest.ACTION_PHASE); try {//w w w .j av a 2 s . c om liferayPortletURL.setWindowState(LiferayWindowState.EXCLUSIVE); } catch (WindowStateException wse) { } String folderId = document.get(Field.ENTRY_CLASS_PK); portletURL.setParameter("struts_action", "/document_library/view"); portletURL.setParameter("folderId", folderId); Summary summary = createSummary(document, Field.TITLE, Field.DESCRIPTION); summary.setMaxContentLength(200); summary.setPortletURL(portletURL); return summary; }
From source file:com.liferay.portlet.documentlibrary.util.DLIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { DLFileEntry dlFileEntry = (DLFileEntry) obj; if (_log.isDebugEnabled()) { _log.debug("Indexing document " + dlFileEntry); }// w ww . ja v a 2s. c o m boolean indexContent = true; InputStream is = null; try { if (PropsValues.DL_FILE_INDEXING_MAX_SIZE == 0) { indexContent = false; } else if (PropsValues.DL_FILE_INDEXING_MAX_SIZE != -1) { if (dlFileEntry.getSize() > PropsValues.DL_FILE_INDEXING_MAX_SIZE) { indexContent = false; } } if (indexContent) { String[] ignoreExtensions = PrefsPropsUtil .getStringArray(PropsKeys.DL_FILE_INDEXING_IGNORE_EXTENSIONS, StringPool.COMMA); if (ArrayUtil.contains(ignoreExtensions, StringPool.PERIOD + dlFileEntry.getExtension())) { indexContent = false; } } if (indexContent) { is = dlFileEntry.getFileVersion().getContentStream(false); } } catch (Exception e) { } if (indexContent && (is == null)) { if (_log.isDebugEnabled()) { _log.debug("Document " + dlFileEntry + " does not have any content"); } return null; } try { Document document = new DocumentImpl(); long fileEntryId = dlFileEntry.getFileEntryId(); document.addUID(PORTLET_ID, fileEntryId); List<AssetCategory> assetCategories = AssetCategoryLocalServiceUtil .getCategories(DLFileEntry.class.getName(), fileEntryId); long[] assetCategoryIds = StringUtil .split(ListUtil.toString(assetCategories, AssetCategory.CATEGORY_ID_ACCESSOR), 0L); document.addKeyword(Field.ASSET_CATEGORY_IDS, assetCategoryIds); String[] assetCategoryNames = StringUtil .split(ListUtil.toString(assetCategories, AssetCategory.NAME_ACCESSOR)); document.addKeyword(Field.ASSET_CATEGORY_NAMES, assetCategoryNames); String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(DLFileEntry.class.getName(), fileEntryId); document.addKeyword(Field.ASSET_TAG_NAMES, assetTagNames); document.addKeyword(Field.COMPANY_ID, dlFileEntry.getCompanyId()); if (indexContent) { try { document.addFile(Field.CONTENT, is, dlFileEntry.getTitle()); } catch (IOException ioe) { throw new SearchException("Cannot extract text from file" + dlFileEntry); } } document.addText(Field.DESCRIPTION, dlFileEntry.getDescription()); document.addKeyword(Field.ENTRY_CLASS_NAME, DLFileEntry.class.getName()); document.addKeyword(Field.ENTRY_CLASS_PK, fileEntryId); document.addKeyword(Field.FOLDER_ID, dlFileEntry.getFolderId()); document.addKeyword(Field.GROUP_ID, getParentGroupId(dlFileEntry.getGroupId())); document.addDate(Field.MODIFIED_DATE, dlFileEntry.getModifiedDate()); document.addKeyword(Field.PORTLET_ID, PORTLET_ID); document.addText(Field.PROPERTIES, dlFileEntry.getLuceneProperties()); document.addKeyword(Field.SCOPE_GROUP_ID, dlFileEntry.getGroupId()); DLFileVersion dlFileVersion = dlFileEntry.getFileVersion(); document.addKeyword(Field.STATUS, dlFileVersion.getStatus()); document.addText(Field.TITLE, dlFileEntry.getTitle()); long userId = dlFileEntry.getUserId(); document.addKeyword(Field.USER_ID, userId); document.addKeyword(Field.USER_NAME, PortalUtil.getUserName(userId, dlFileEntry.getUserName()), true); document.addKeyword("dataRepositoryId", dlFileEntry.getDataRepositoryId()); document.addKeyword("extension", dlFileEntry.getExtension()); document.addKeyword("fileEntryTypeId", dlFileEntry.getFileEntryTypeId()); document.addKeyword("path", dlFileEntry.getTitle()); ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(dlFileEntry.getCompanyId(), DLFileEntry.class.getName(), dlFileVersion.getFileVersionId()); ExpandoBridgeIndexerUtil.addAttributes(document, expandoBridge); addFileEntryTypeAttributes(document, dlFileVersion); if (_log.isDebugEnabled()) { _log.debug("Document " + dlFileEntry + " indexed successfully"); } return document; } finally { if (is != null) { try { is.close(); } catch (IOException ioe) { } } } }
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 w w w .j a va 2 s . co 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 ww . jav a 2 s .c o m*/ } }
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 . ja va2 s . c o 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
protected String getBasicContentSummary(Document document, Locale snippetLocale) { String prefix = Field.SNIPPET + StringPool.UNDERLINE; String content = document.get(snippetLocale, prefix + Field.DESCRIPTION, prefix + Field.CONTENT); if (Validator.isBlank(content)) { content = document.get(snippetLocale, Field.DESCRIPTION, Field.CONTENT); }//from w w w . jav a2 s. c om if (content.length() > 200) { content = StringUtil.shorten(content, 200); } return content; }
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 www. j a v a 2 s.com } }
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); }// ww w .j a v a2 s. c o 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.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 .j a 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); } }