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.trash.internal.search.TrashIndexer.java
License:Open Source License
@Override public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter, SearchContext searchContext) throws Exception { if (searchContext.getAttributes() == null) { return;/*from w w w .j ava 2 s . c o m*/ } addSearchLocalizedTerm(searchQuery, searchContext, Field.CONTENT, true); addSearchLocalizedTerm(searchQuery, searchContext, Field.DESCRIPTION, true); addSearchTerm(searchQuery, searchContext, Field.REMOVED_BY_USER_NAME, true); addSearchLocalizedTerm(searchQuery, searchContext, Field.TITLE, true); addSearchTerm(searchQuery, searchContext, Field.TYPE, false); addSearchTerm(searchQuery, searchContext, Field.USER_NAME, true); }
From source file:com.liferay.user.groups.admin.web.internal.search.UserGroupIndexer.java
License:Open Source License
@Override protected Document doGetDocument(UserGroup userGroup) throws Exception { Document document = getBaseModelDocument(CLASS_NAME, userGroup); document.addKeyword(Field.COMPANY_ID, userGroup.getCompanyId()); document.addText(Field.DESCRIPTION, userGroup.getDescription()); document.addText(Field.NAME, userGroup.getName()); document.addKeyword(Field.USER_GROUP_ID, userGroup.getUserGroupId()); return document; }
From source file:com.liferay.wiki.search.WikiNodeIndexer.java
License:Open Source License
@Override protected Document doGetDocument(WikiNode wikiNode) throws Exception { Document document = getBaseModelDocument(CLASS_NAME, wikiNode); document.addText(Field.DESCRIPTION, wikiNode.getDescription()); String title = wikiNode.getName(); if (wikiNode.isInTrash()) { title = TrashUtil.getOriginalTitle(title); }//from w w w. j a va2s .c o m document.addText(Field.TITLE, title); return document; }
From source file:com.vportal.portlet.vcms.service.impl.VcmsArticleServiceImpl.java
License:Open Source License
public Hits search(long companyId, long groupId, long userId, String keywords, int start, int end) throws SystemException { try {/* w ww .jav a 2 s. c o m*/ BooleanQuery contextQuery = BooleanQueryFactoryUtil.create(); contextQuery.addRequiredTerm(Field.PORTLET_ID, PortletKeysExt.VCMS); if (groupId > 0) { contextQuery.addRequiredTerm(Field.GROUP_ID, groupId); } if (userId > 0) { contextQuery.addRequiredTerm(Field.USER_ID, userId); } BooleanQuery searchQuery = BooleanQueryFactoryUtil.create(); if (Validator.isNotNull(keywords)) { searchQuery.addTerm(Field.TITLE, keywords); searchQuery.addTerm(Field.DESCRIPTION, keywords); searchQuery.addTerm(Field.CONTENT, keywords); /*searchQuery.addTerm(Field.TAGS_ENTRIES, keywords);*/ searchQuery.addTerm(Field.ASSET_TAG_NAMES, 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); } }
From source file:com.vportal.portlet.vcms.util.SearchIndexer.java
License:Open Source License
public static Document getAddArticleDocument(long companyId, long groupId, String articleId, String title, String description, String content) throws NumberFormatException, PortalException, SystemException { InputStream is = null;// w w w . j a v a 2 s . c o m List addedAttachments = AttachmentLocalServiceUtil.getAttachments(Long.parseLong(articleId), VcmsArticle.class); for (int i = 0; i < addedAttachments.size(); i++) { Attachment attachment = (Attachment) addedAttachments.get(i); DLFileEntry entry = null; try { entry = (DLFileEntry) DLFileEntryLocalServiceUtil.getFileEntry(attachment.getFileEntryId()); /*String fileExtension = entry.getTitleWithExtension(); String extension = fileExtension.substring(fileExtension.lastIndexOf(".")+1,fileExtension.length());*/ String extension = entry.getExtension(); is = DLLocalServiceUtil.getFileAsStream(companyId, entry.getFolderId(), entry.getName()); content = FileUtilExt.getContentFile(is, content, extension); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } content = HtmlUtil.extractText(content); Document doc = new DocumentImpl(); doc.addUID(PORTLET_ID, articleId); doc.addKeyword(Field.COMPANY_ID, companyId); doc.addKeyword(Field.PORTLET_ID, PORTLET_ID); doc.addKeyword(Field.GROUP_ID, groupId); doc.addText(Field.TITLE, title); doc.addText(Field.CONTENT, content); doc.addText(Field.DESCRIPTION, description); doc.addModifiedDate(); doc.addKeyword(Field.ENTRY_CLASS_NAME, VcmsArticle.class.getName()); doc.addKeyword(Field.ENTRY_CLASS_PK, articleId); return doc; }
From source file:org.fit.portlet.service.service.impl.InserFitxaPersonalLocalServiceImpl.java
License:Open Source License
private Hits searchFitxaPersonalHits(long companyId, long groupId, long[] organizationIds, String searchText, long tecnicReferent, long codiProjecte, long serveiSocial, int start, int end, String orderByCol, String orderByType) {//from ww w. j a v a2s .co m try { String searchEngineId = SearchEngineUtil.getDefaultSearchEngineId(); SearchEngine searchEngine = SearchEngineUtil.getSearchEngine(searchEngineId); BooleanQueryFactory booleanQueryFactory = searchEngine.getBooleanQueryFactory(); BooleanQuery query = booleanQueryFactory.create(); // Context query query.addRequiredTerm(Field.COMPANY_ID, companyId); query.addRequiredTerm(Field.CLASS_NAME_ID, InserFitxaPersonal.class.getName()); if (groupId > -1) { query.addRequiredTerm(Field.GROUP_ID, groupId); } if (Validator.isNotNull(organizationIds)) { BooleanQuery organizationQuery = booleanQueryFactory.create(); if (organizationIds.length > 1 && organizationIds[0] == -2) { BooleanQuery q = booleanQueryFactory.create(); SearchContext searchContext = new SearchContext(); TermRangeQuery oq = TermRangeQueryFactoryUtil.create(searchContext, Field.ORGANIZATION_ID, "-1", "0", true, false); q.add(oq, BooleanClauseOccur.SHOULD); // L'usuari vol veure tots els que estan sense localitzaci query.add(q, BooleanClauseOccur.MUST); } else { for (long idorg : organizationIds) { if (idorg > -1) { organizationQuery.addTerm(Field.ORGANIZATION_ID, idorg); } } } if (organizationQuery.hasClauses()) { query.add(organizationQuery, BooleanClauseOccur.MUST); } } if (Validator.isNotNull(searchText)) { BooleanQuery searchTextQuery = booleanQueryFactory.create(); searchTextQuery.addExactTerm(GestioPersonesIndexConstants.NUM_EXPEDIENT, searchText); searchTextQuery.addExactTerm(GestioPersonesIndexConstants.DNI, searchText); searchTextQuery.addTerm(Field.DESCRIPTION, searchText); searchTextQuery.addTerm(Field.TITLE, searchText); searchTextQuery.addTerm(GestioPersonesIndexConstants.TECNIC_REFERENT, searchText); searchTextQuery.addTerm(GestioPersonesIndexConstants.OBSERVACIONS, searchText); searchTextQuery.addTerm(GestioPersonesIndexConstants.SEGUIMENT_ITINERARI, searchText); searchTextQuery.addTerm(GestioPersonesIndexConstants.SEGUIMENT_ITINERARI, searchText); query.add(searchTextQuery, BooleanClauseOccur.MUST); } // Cerca avanada if (tecnicReferent > -1) { query.addRequiredTerm(GestioPersonesIndexConstants.TECNIC_REFERENT_ID, tecnicReferent); } if (codiProjecte > -1) { query.addRequiredTerm(GestioPersonesIndexConstants.CODI_PROJECTE_ID, codiProjecte); } if (serveiSocial > -1) { query.addRequiredTerm(GestioPersonesIndexConstants.SERVEI_SOCIAL_ID, serveiSocial); } Sort sort = new Sort(); sort.setReverse(false); if (Validator.isNotNull(orderByCol)) { int type = getType(orderByCol); sort.setType(type); sort.setFieldName(orderByCol); if (Validator.isNotNull(orderByType)) { if (orderByType.equalsIgnoreCase("desc")) { sort.setReverse(true); } } } log.info(query.toString() + " " + sort.toString()); Hits search = SearchEngineUtil.search(searchEngineId, companyId, query, sort, start, end); return search; } catch (SearchException e) { log.error(e); } catch (ParseException e) { log.error(e); } return null; }
From source file:org.xcolab.portlets.search.Indexer.java
License:Open Source License
public static Document getArticleDocument(long companyId, long groupId, String articleId, double version, String title, String description, String content, String type, Date displayDate, String[] tagsCategories, String[] tagsEntries, ExpandoBridge expandoBridge) { if ((content != null) && ((content.indexOf("<dynamic-content") != -1) || (content.indexOf("<static-content") != -1))) { content = _getIndexableContent(content); content = StringUtil.replace(content, "<![CDATA[", StringPool.BLANK); content = StringUtil.replace(content, "]]>", StringPool.BLANK); }//from ww w .j a v a 2 s .c om content = StringUtil.replace(content, "&", "&"); content = StringUtil.replace(content, "<", "<"); content = StringUtil.replace(content, ">", ">"); content = HtmlUtil.extractText(content); Document doc = new DocumentImpl(); // check if this is an most recent version of an article JournalArticle article; boolean isOld = false; try { article = JournalArticleLocalServiceUtil.getArticle(groupId, articleId); if (article.getVersion() != version) { isOld = true; } } catch (Exception e1) { e1.printStackTrace(); // ignore } if (isOld) { doc.addUID(PORTLET_ID, articleId, "old"); } else { doc.addUID(PORTLET_ID, articleId); } doc.addModifiedDate(displayDate); doc.addKeyword(Field.COMPANY_ID, companyId); doc.addKeyword(Field.PORTLET_ID, PORTLET_ID); doc.addKeyword(Field.GROUP_ID, groupId); doc.addText(Field.TITLE, title); doc.addText(Field.CONTENT, content); doc.addText(Field.DESCRIPTION, description); doc.addKeyword(Field.ENTRY_CLASS_PK, articleId); doc.addKeyword(Field.VERSION, version); doc.addKeyword(Field.TYPE, type); ExpandoBridgeIndexerUtil.addAttributes(doc, expandoBridge); try { Layout pageLayout = getLayoutForContent(articleId); if (pageLayout != null) { Layout tmp = pageLayout; boolean isAbout = false; while (tmp != null && !isAbout) { if (tmp.getFriendlyURL().toLowerCase().contains("/about") || tmp.getFriendlyURL().toLowerCase().contains("/contests")) { isAbout = true; } if (tmp.getParentLayoutId() > 0) { try { tmp = LayoutLocalServiceUtil.getLayout(tmp.getGroupId(), tmp.getPrivateLayout(), tmp.getParentLayoutId()); } catch (com.liferay.portal.NoSuchLayoutException e) { tmp = null; } catch (PortalException e) { tmp = null; } } else { tmp = null; } } if (isAbout) { doc.addKeyword("PAGE_URL", pageLayout.getFriendlyURL()); doc.addKeyword(Field.ENTRY_CLASS_NAME, JournalArticle.class.getName() + ".index"); } } else { doc.addKeyword(Field.ENTRY_CLASS_NAME, JournalArticle.class.getName()); } } catch (SystemException e) { doc.addKeyword(Field.ENTRY_CLASS_NAME, JournalArticle.class.getName()); e.printStackTrace(); } return doc; }
From source file:org.xcolab.portlets.search.Indexer.java
License:Open Source License
@Override public Document getDocument(Object obj) throws SearchException { JournalArticle article = (JournalArticle) obj; String articleId = article.getArticleId(); long groupId = article.getGroupId(); long companyId = article.getCompanyId(); double version = article.getVersion(); String content = article.getContent(); String title = article.getTitle(); Date displayDate = article.getDisplayDate(); String description = article.getDescription(); String type = article.getType(); ExpandoBridge expandoBridge = article.getExpandoBridge(); if ((content != null) && ((content.indexOf("<dynamic-content") != -1) || (content.indexOf("<static-content") != -1))) { content = _getIndexableContent(content); content = StringUtil.replace(content, "<![CDATA[", StringPool.BLANK); content = StringUtil.replace(content, "]]>", StringPool.BLANK); }/*from www .j a v a 2s .c o m*/ content = StringUtil.replace(content, "&", "&"); content = StringUtil.replace(content, "<", "<"); content = StringUtil.replace(content, ">", ">"); content = HtmlUtil.extractText(content); Document doc = new DocumentImpl(); // check if this is an most recent version of an article boolean isOld = false; try { JournalArticle tmpArticle = JournalArticleLocalServiceUtil.getArticle(groupId, String.valueOf(articleId)); if (article.getVersion() != version) { isOld = true; } } catch (Exception e1) { e1.printStackTrace(); // ignore } if (isOld) { doc.addUID(PORTLET_ID, articleId, "old"); } else { doc.addUID(PORTLET_ID, articleId); } doc.addModifiedDate(displayDate); doc.addKeyword(Field.COMPANY_ID, companyId); doc.addKeyword(Field.PORTLET_ID, PORTLET_ID); doc.addKeyword(Field.GROUP_ID, groupId); doc.addText(Field.TITLE, title); doc.addText(Field.CONTENT, content); doc.addText(Field.DESCRIPTION, description); doc.addKeyword(Field.ENTRY_CLASS_PK, articleId); doc.addKeyword(Field.VERSION, version); doc.addKeyword(Field.TYPE, type); ExpandoBridgeIndexerUtil.addAttributes(doc, expandoBridge); try { Layout pageLayout = getLayoutForContent(articleId); if (pageLayout != null) { Layout tmp = pageLayout; boolean isAbout = false; while (tmp != null && !isAbout) { if (tmp.getFriendlyURL().toLowerCase().contains("/about") || tmp.getFriendlyURL().toLowerCase().contains("/contests")) { isAbout = true; } if (tmp.getParentLayoutId() > 0) { try { tmp = LayoutLocalServiceUtil.getLayout(tmp.getGroupId(), tmp.getPrivateLayout(), tmp.getParentLayoutId()); } catch (com.liferay.portal.NoSuchLayoutException e) { tmp = null; } catch (PortalException e) { tmp = null; } } else { tmp = null; } } if (isAbout) { doc.addKeyword("PAGE_URL", pageLayout.getFriendlyURL()); doc.addKeyword(Field.ENTRY_CLASS_NAME, JournalArticle.class.getName() + ".index"); } } else { doc.addKeyword(Field.ENTRY_CLASS_NAME, JournalArticle.class.getName()); } } catch (SystemException e) { doc.addKeyword(Field.ENTRY_CLASS_NAME, JournalArticle.class.getName()); e.printStackTrace(); } return doc; }