List of usage examples for com.liferay.portal.kernel.search Field USER_NAME
String USER_NAME
To view the source code for com.liferay.portal.kernel.search Field USER_NAME.
Click Source Link
From source file:com.liferay.knowledgebase.admin.util.KBArticleIndexer.java
License:Open Source License
@Override public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter, SearchContext searchContext) throws Exception { addSearchTerm(searchQuery, searchContext, Field.CONTENT, true); addSearchTerm(searchQuery, searchContext, Field.DESCRIPTION, true); addSearchTerm(searchQuery, searchContext, Field.TITLE, true); addSearchTerm(searchQuery, searchContext, Field.USER_NAME, true); }
From source file:com.liferay.knowledgebase.util.KnowledgeBaseUtil.java
License:Open Source License
public static Sort[] getKBArticleSorts(String orderByCol, String orderByType) { if (Validator.isNull(orderByCol) || Validator.isNull(orderByType)) { return SortFactoryUtil.getDefaultSorts(); }/*from w w w .j a v a 2 s. c o m*/ boolean reverse = true; if (orderByType.equals("asc")) { reverse = false; } if (orderByCol.equals("create-date")) { String fieldName = Field.CREATE_DATE; return new Sort[] { SortFactoryUtil.create(fieldName, Sort.LONG_TYPE, reverse), SortFactoryUtil.create(null, Sort.SCORE_TYPE, false) }; } else if (orderByCol.equals("modified-date")) { String fieldName = Field.MODIFIED_DATE; return new Sort[] { SortFactoryUtil.create(fieldName, Sort.LONG_TYPE, reverse), SortFactoryUtil.create(null, Sort.SCORE_TYPE, false) }; } else if (orderByCol.equals("score")) { String fieldName = null; return new Sort[] { SortFactoryUtil.create(fieldName, Sort.SCORE_TYPE, !reverse), SortFactoryUtil.create(Field.MODIFIED_DATE, Sort.LONG_TYPE, true) }; } else if (orderByCol.equals("title")) { String fieldName = "titleKeyword"; return new Sort[] { SortFactoryUtil.create(fieldName, Sort.STRING_TYPE, reverse), SortFactoryUtil.create(null, Sort.SCORE_TYPE, false) }; } else if (orderByCol.equals("user-name")) { String fieldName = Field.USER_NAME; return new Sort[] { SortFactoryUtil.create(fieldName, Sort.STRING_TYPE, reverse), SortFactoryUtil.create(null, Sort.SCORE_TYPE, false) }; } return SortFactoryUtil.getDefaultSorts(); }
From source file:com.liferay.message.boards.internal.search.MBMessageIndexer.java
License:Open Source License
@Override protected Document doGetDocument(MBMessage mbMessage) throws Exception { Document document = getBaseModelDocument(CLASS_NAME, mbMessage); document.addKeyword(Field.CATEGORY_ID, mbMessage.getCategoryId()); document.addText(Field.CONTENT, processContent(mbMessage)); document.addKeyword(Field.ROOT_ENTRY_CLASS_PK, mbMessage.getRootMessageId()); document.addText(Field.TITLE, mbMessage.getSubject()); if (mbMessage.isAnonymous()) { document.remove(Field.USER_NAME); }/*from w w w .ja v a 2 s . c om*/ MBDiscussion discussion = mbDiscussionLocalService.fetchThreadDiscussion(mbMessage.getThreadId()); if (discussion == null) { document.addKeyword("discussion", false); } else { document.addKeyword("discussion", true); } document.addKeyword("threadId", mbMessage.getThreadId()); if (mbMessage.isDiscussion()) { List<RelatedEntryIndexer> relatedEntryIndexers = RelatedEntryIndexerRegistryUtil .getRelatedEntryIndexers(mbMessage.getClassName()); if (relatedEntryIndexers != null) { for (RelatedEntryIndexer relatedEntryIndexer : relatedEntryIndexers) { Comment comment = commentManager.fetchComment(mbMessage.getMessageId()); if (comment != null) { relatedEntryIndexer.addRelatedEntryFields(document, comment); document.addKeyword(Field.RELATED_ENTRY, true); } } } } return document; }
From source file:com.liferay.portlet.asset.service.impl.AssetEntryLocalServiceImpl.java
License:Open Source License
@Override public Hits search(long companyId, long[] groupIds, long userId, String className, String userName, String title, String description, String assetCategoryIds, String assetTagNames, int status, boolean andSearch, int start, int end) throws SystemException { try {//from ww w .j av a 2s. co m SearchContext searchContext = new SearchContext(); Facet assetEntriesFacet = new AssetEntriesFacet(searchContext); assetEntriesFacet.setStatic(true); searchContext.addFacet(assetEntriesFacet); Facet scopeFacet = new ScopeFacet(searchContext); scopeFacet.setStatic(true); searchContext.addFacet(scopeFacet); searchContext.setAndSearch(andSearch); searchContext.setAssetCategoryIds(StringUtil.split(assetCategoryIds, 0L)); searchContext.setAssetTagNames(StringUtil.split(assetTagNames)); searchContext.setAttribute(Field.DESCRIPTION, description); searchContext.setAttribute(Field.TITLE, title); searchContext.setAttribute(Field.USER_NAME, userName); searchContext.setAttribute("paginationType", "regular"); searchContext.setAttribute("status", status); searchContext.setCompanyId(companyId); searchContext.setEnd(end); searchContext.setEntryClassNames(getClassNames(companyId, className)); searchContext.setGroupIds(groupIds); QueryConfig queryConfig = new QueryConfig(); queryConfig.setHighlightEnabled(false); queryConfig.setScoreEnabled(false); searchContext.setQueryConfig(queryConfig); searchContext.setStart(start); searchContext.setUserId(userId); Indexer indexer = FacetedSearcher.getInstance(); return indexer.search(searchContext); } catch (Exception e) { throw new SystemException(e); } }
From source file:com.liferay.portlet.assetpublisher.util.AssetIndexer.java
License:Open Source License
@Override public void postProcessSearchQuery(BooleanQuery searchQuery, SearchContext searchContext) throws Exception { if (searchContext.getAttributes() == null) { return;/*w w w . j a v a 2 s . c o m*/ } addSearchTerm(searchQuery, searchContext, Field.DESCRIPTION, false); addSearchTerm(searchQuery, searchContext, Field.TITLE, false); addSearchTerm(searchQuery, searchContext, Field.USER_NAME, false); }
From source file:com.liferay.portlet.documentlibrary.util.DLFileEntryIndexer.java
License:Open Source License
@Override public void postProcessSearchQuery(BooleanQuery searchQuery, SearchContext searchContext) throws Exception { Group group = GroupLocalServiceUtil.getCompanyGroup(searchContext.getCompanyId()); DDMStructure tikaRawMetadataStructure = DDMStructureLocalServiceUtil.fetchStructure(group.getGroupId(), PortalUtil.getClassNameId(RawMetadataProcessor.class), "TikaRawMetadata"); if (tikaRawMetadataStructure != null) { addSearchDDMStruture(searchQuery, searchContext, tikaRawMetadataStructure); }/* ww w .ja v a2s . com*/ String keywords = searchContext.getKeywords(); if (Validator.isNull(keywords)) { addSearchTerm(searchQuery, searchContext, Field.DESCRIPTION, false); addSearchTerm(searchQuery, searchContext, Field.TITLE, false); addSearchTerm(searchQuery, searchContext, Field.USER_NAME, false); } addSearchTerm(searchQuery, searchContext, "ddmContent", false); addSearchTerm(searchQuery, searchContext, "extension", false); addSearchTerm(searchQuery, searchContext, "fileEntryTypeId", false); addSearchTerm(searchQuery, searchContext, "path", 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 source file:com.liferay.portlet.documentlibrary.util.DLIndexer.java
License:Open Source License
@Override public void postProcessSearchQuery(BooleanQuery searchQuery, SearchContext searchContext) throws Exception { Set<DDMStructure> ddmStructuresSet = new TreeSet<DDMStructure>(); long[] groupIds = searchContext.getGroupIds(); if ((groupIds != null) && (groupIds.length > 0)) { List<DLFileEntryType> dlFileEntryTypes = DLFileEntryTypeLocalServiceUtil.getFileEntryTypes(groupIds); for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) { ddmStructuresSet.addAll(dlFileEntryType.getDDMStructures()); }/*from w w w . ja va 2s .c om*/ } Group group = GroupLocalServiceUtil.getCompanyGroup(searchContext.getCompanyId()); DDMStructure tikaRawMetadataStructure = DDMStructureLocalServiceUtil.fetchStructure(group.getGroupId(), "TikaRawMetadata"); if (tikaRawMetadataStructure != null) { ddmStructuresSet.add(tikaRawMetadataStructure); } for (DDMStructure ddmStructure : ddmStructuresSet) { addSearchDDMStruture(searchQuery, searchContext, ddmStructure); } addSearchTerm(searchQuery, searchContext, Field.USER_NAME, false); addSearchTerm(searchQuery, searchContext, "extension", false); addSearchTerm(searchQuery, searchContext, "fileEntryTypeId", false); addSearchTerm(searchQuery, searchContext, "path", 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 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 w w . j ava2s . 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.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 . j av a 2s .c o m*/ } }
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 ww .j a va 2 s .c o m*/ try { MBDiscussionLocalServiceUtil.getThreadDiscussion(message.getThreadId()); document.addKeyword("discussion", true); } catch (NoSuchDiscussionException nsde) { document.addKeyword("discussion", false); } document.addKeyword("threadId", message.getThreadId()); return document; }