List of usage examples for com.liferay.portal.kernel.search Document addKeyword
public void addKeyword(String name, String[] values);
From source file:com.inkwell.internet.slogan.search.SloganIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { Slogan slogan = (Slogan) obj;/*from w ww . j a v a 2s . c o m*/ long companyId = slogan.getCompanyId(); long groupId = getParentGroupId(slogan.getGroupId()); long scopeGroupId = slogan.getGroupId(); long userId = slogan.getUserId(); long resourcePrimKey = slogan.getPrimaryKey(); String title = slogan.getSloganText(); String content = slogan.getSloganText(); String description = slogan.getSloganText(); Date modifiedDate = slogan.getSloganDate(); long[] assetCategoryIds = AssetCategoryLocalServiceUtil.getCategoryIds(Slogan.class.getName(), resourcePrimKey); List<AssetCategory> categories = AssetCategoryLocalServiceUtil.getCategories(Slogan.class.getName(), resourcePrimKey); String[] assetCategoryNames = StringUtil.split(ListUtil.toString(categories, "name")); // EE lets you do this quicker: // String[] assetCategoryNames = // AssetCategoryLocalServiceUtil.getCategoryNames( // Slogan.class.getName(), resourcePrimKey); String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(Slogan.class.getName(), resourcePrimKey); Document document = new DocumentImpl(); document.addUID(PORTLET_ID, resourcePrimKey); document.addModifiedDate(modifiedDate); document.addKeyword(Field.COMPANY_ID, companyId); document.addKeyword(Field.PORTLET_ID, PORTLET_ID); document.addKeyword(Field.GROUP_ID, groupId); document.addKeyword(Field.SCOPE_GROUP_ID, scopeGroupId); document.addKeyword(Field.USER_ID, userId); document.addText(Field.TITLE, title); document.addText(Field.CONTENT, content); document.addText(Field.DESCRIPTION, description); document.addKeyword(Field.ASSET_CATEGORY_IDS, assetCategoryIds); document.addKeyword("assetCategoryNames", assetCategoryNames); //document.addKeyword(Field.ASSET_CATEGORY_NAMES, assetCategoryNames); document.addKeyword(Field.ASSET_TAG_NAMES, assetTagNames); document.addKeyword(Field.ENTRY_CLASS_NAME, Slogan.class.getName()); document.addKeyword(Field.ENTRY_CLASS_PK, resourcePrimKey); return document; }
From source file:com.liferay.asset.categories.internal.search.AssetCategoryIndexer.java
License:Open Source License
@Override protected Document doGetDocument(AssetCategory assetCategory) throws Exception { if (_log.isDebugEnabled()) { _log.debug("Indexing asset category " + assetCategory); }/* w w w .j a v a2 s . co m*/ Document document = getBaseModelDocument(CLASS_NAME, assetCategory); document.addKeyword(Field.ASSET_CATEGORY_ID, assetCategory.getCategoryId()); List<AssetCategory> categories = new ArrayList<>(1); categories.add(assetCategory); addSearchAssetCategoryTitles(document, Field.ASSET_CATEGORY_TITLE, categories); document.addKeyword(Field.ASSET_PARENT_CATEGORY_ID, assetCategory.getParentCategoryId()); document.addKeyword(Field.ASSET_VOCABULARY_ID, assetCategory.getVocabularyId()); Locale siteDefaultLocale = _portal.getSiteDefaultLocale(assetCategory.getGroupId()); addLocalizedField(document, Field.DESCRIPTION, siteDefaultLocale, assetCategory.getDescriptionMap()); document.addText(Field.NAME, assetCategory.getName()); addLocalizedField(document, Field.TITLE, siteDefaultLocale, assetCategory.getTitleMap()); document.addKeyword("leftCategoryId", assetCategory.getLeftCategoryId()); if (_log.isDebugEnabled()) { _log.debug("Document " + assetCategory + " indexed successfully"); } return document; }
From source file:com.liferay.asset.categories.internal.search.AssetVocabularyIndexer.java
License:Open Source License
@Override protected Document doGetDocument(AssetVocabulary assetVocabulary) throws Exception { if (_log.isDebugEnabled()) { _log.debug("Indexing asset vocabulary " + assetVocabulary); }// w w w .jav a2 s .c o m Document document = getBaseModelDocument(CLASS_NAME, assetVocabulary); document.addKeyword(Field.ASSET_VOCABULARY_ID, assetVocabulary.getVocabularyId()); Locale siteDefaultLocale = _portal.getSiteDefaultLocale(assetVocabulary.getGroupId()); addLocalizedField(document, Field.DESCRIPTION, siteDefaultLocale, assetVocabulary.getDescriptionMap()); document.addText(Field.NAME, assetVocabulary.getName()); addLocalizedField(document, Field.TITLE, siteDefaultLocale, assetVocabulary.getTitleMap()); if (_log.isDebugEnabled()) { _log.debug("Document " + assetVocabulary + " indexed successfully"); } return document; }
From source file:com.liferay.bookmarks.search.BookmarksEntryIndexer.java
License:Open Source License
@Override protected Document doGetDocument(BookmarksEntry bookmarksEntry) throws Exception { Document document = getBaseModelDocument(CLASS_NAME, bookmarksEntry); document.addText(Field.DESCRIPTION, bookmarksEntry.getDescription()); document.addKeyword(Field.FOLDER_ID, bookmarksEntry.getFolderId()); document.addText(Field.TITLE, bookmarksEntry.getName()); document.addKeyword(Field.TREE_PATH, StringUtil.split(bookmarksEntry.getTreePath(), CharPool.SLASH)); document.addText(Field.URL, bookmarksEntry.getUrl()); return document; }
From source file:com.liferay.bookmarks.search.BookmarksFolderIndexer.java
License:Open Source License
@Override protected Document doGetDocument(BookmarksFolder bookmarksFolder) throws Exception { if (_log.isDebugEnabled()) { _log.debug("Indexing folder " + bookmarksFolder); }//from w ww.ja v a2 s .c o m Document document = getBaseModelDocument(CLASS_NAME, bookmarksFolder); document.addText(Field.DESCRIPTION, bookmarksFolder.getDescription()); document.addKeyword(Field.FOLDER_ID, bookmarksFolder.getParentFolderId()); document.addText(Field.TITLE, bookmarksFolder.getName()); document.addKeyword(Field.TREE_PATH, StringUtil.split(bookmarksFolder.getTreePath(), CharPool.SLASH)); if (_log.isDebugEnabled()) { _log.debug("Document " + bookmarksFolder + " indexed successfully"); } return document; }
From source file:com.liferay.calendar.search.CalendarBookingIndexer.java
License:Open Source License
@Override protected Document doGetDocument(CalendarBooking calendarBooking) throws Exception { Document document = getBaseModelDocument(CLASS_NAME, calendarBooking); document.addKeyword(Field.CLASS_NAME_ID, _classNameLocalService.getClassNameId(Calendar.class)); document.addKeyword(Field.CLASS_PK, calendarBooking.getCalendarId()); Locale defaultLocale = LocaleUtil.getSiteDefault(); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); String[] descriptionLanguageIds = getLanguageIds(defaultLanguageId, calendarBooking.getDescription()); for (String descriptionLanguageId : descriptionLanguageIds) { String description = calendarBooking.getDescription(descriptionLanguageId); document.addText(LocalizationUtil.getLocalizedName(Field.DESCRIPTION, descriptionLanguageId), description);//from w ww.j a v a 2 s . c om } document.addKeyword(Field.RELATED_ENTRY, true); String[] titleLanguageIds = getLanguageIds(defaultLanguageId, calendarBooking.getTitle()); for (String titleLanguageId : titleLanguageIds) { String title = calendarBooking.getTitle(titleLanguageId); document.addText(LocalizationUtil.getLocalizedName(Field.TITLE, titleLanguageId), title); } document.addKeyword(Field.VIEW_ACTION_ID, CalendarActionKeys.VIEW_BOOKING_DETAILS); String calendarBookingId = String.valueOf(calendarBooking.getCalendarBookingId()); if (calendarBooking.isInTrash()) { calendarBookingId = TrashUtil.getOriginalTitle(calendarBookingId); } document.addKeyword("calendarBookingId", calendarBookingId); document.addText("defaultLanguageId", defaultLanguageId); document.addNumber("endTime", calendarBooking.getEndTime()); document.addText("location", calendarBooking.getLocation()); document.addNumber("startTime", calendarBooking.getStartTime()); return document; }
From source file:com.liferay.calendar.search.CalendarIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Calendar calendar) throws Exception { Document document = getBaseModelDocument(CLASS_NAME, calendar); document.addLocalizedKeyword(Field.DESCRIPTION, calendar.getDescriptionMap(), true); document.addLocalizedKeyword(Field.NAME, calendar.getNameMap(), true); document.addKeyword("calendarId", calendar.getCalendarId()); Locale defaultLocale = LocaleUtil.getSiteDefault(); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); document.addText("defaultLanguageId", defaultLanguageId); CalendarResource calendarResource = calendar.getCalendarResource(); document.addLocalizedKeyword("resourceName", calendarResource.getNameMap(), true); return document; }
From source file:com.liferay.calendar.search.test.CalendarBookingIndexerIndexedFieldsTest.java
License:Open Source License
protected void adjustDatePrecision(String field, Document document, DateFormat dateFormat) throws Exception { Date date1 = document.getDate(field); Date date2 = dateFormat.parse(dateFormat.format(date1)); document.addDate(field, date2);/*ww w .j av a 2 s .com*/ document.addKeyword(field.concat("_sortable"), date2.getTime()); }
From source file:com.liferay.calendar.util.CalendarBookingIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { CalendarBooking calendarBooking = (CalendarBooking) obj; Document document = getBaseModelDocument(PORTLET_ID, calendarBooking); Locale defaultLocale = LocaleUtil.getSiteDefault(); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); String descriptionDefaultLanguageId = LocalizationUtil .getDefaultLanguageId(calendarBooking.getDescription()); String[] descriptionLanguageIds = getLanguageIds(defaultLanguageId, calendarBooking.getDescription()); for (String descriptionLanguageId : descriptionLanguageIds) { String description = calendarBooking.getDescription(descriptionLanguageId); if (descriptionLanguageId.equals(descriptionDefaultLanguageId)) { document.addText(Field.DESCRIPTION, description); }//from w w w. ja v a 2 s . co m document.addText(Field.DESCRIPTION.concat(StringPool.UNDERLINE).concat(descriptionLanguageId), description); } String titleDefaultLanguageId = LocalizationUtil.getDefaultLanguageId(calendarBooking.getTitle()); String[] titleLanguageIds = getLanguageIds(defaultLanguageId, calendarBooking.getTitle()); for (String titleLanguageId : titleLanguageIds) { String title = calendarBooking.getTitle(titleLanguageId); if (titleLanguageId.equals(titleDefaultLanguageId)) { document.addText(Field.TITLE, title); } document.addText(Field.TITLE.concat(StringPool.UNDERLINE).concat(titleLanguageId), title); } String calendarBookingId = String.valueOf(calendarBooking.getCalendarBookingId()); if (calendarBooking.isInTrash()) { calendarBookingId = TrashUtil.getOriginalTitle(calendarBookingId); } document.addKeyword("calendarBookingId", calendarBookingId); document.addText("defaultLanguageId", defaultLanguageId); document.addNumber("endTime", calendarBooking.getEndTime()); document.addText("location", calendarBooking.getLocation()); document.addNumber("startTime", calendarBooking.getStartTime()); return document; }
From source file:com.liferay.calendar.util.CalendarIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object object) throws Exception { Calendar calendar = (Calendar) object; Document document = getBaseModelDocument(CLASS_NAME, calendar); document.addLocalizedText(Field.DESCRIPTION, calendar.getDescriptionMap()); document.addLocalizedText(Field.NAME, calendar.getNameMap()); document.addKeyword("calendarId", calendar.getCalendarId()); Locale defaultLocale = LocaleUtil.getSiteDefault(); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); document.addText("defaultLanguageId", defaultLanguageId); CalendarResource calendarResource = calendar.getCalendarResource(); document.addLocalizedText("resourceName", calendarResource.getNameMap()); return document; }