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.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); }/* www . java 2s . c o 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.CalendarBookingIndexer.java
License:Open Source License
@Override protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL, PortletRequest portletRequest, PortletResponse portletResponse) { String calendarBookingId = document.get(Field.ENTRY_CLASS_PK); portletURL.setParameter("mvcPath", "/view_calendar_booking.jsp"); portletURL.setParameter("calendarBookingId", calendarBookingId); Summary summary = createSummary(document, Field.TITLE, Field.DESCRIPTION); summary.setMaxContentLength(200);//from www. j a v a 2 s. c om summary.setPortletURL(portletURL); return summary; }
From source file:com.liferay.configuration.admin.web.internal.search.ConfigurationModelIndexer.java
License:Open Source License
@Activate protected void activate(BundleContext bundleContext) { setCommitImmediately(false);/*from ww w . j a v a2 s . c o m*/ setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.DESCRIPTION, Field.ENTRY_CLASS_NAME, Field.TITLE, Field.UID, FieldNames.CONFIGURATION_MODEL_ATTRIBUTE_DESCRIPTION, FieldNames.CONFIGURATION_MODEL_ATTRIBUTE_NAME, FieldNames.CONFIGURATION_MODEL_FACTORY_PID, FieldNames.CONFIGURATION_MODEL_ID); setFilterSearch(false); setPermissionAware(false); setSelectAllLocales(false); setStagingAware(false); }
From source file:com.liferay.configuration.admin.web.internal.search.ConfigurationModelIndexer.java
License:Open Source License
@Override protected BooleanQuery createFullQuery(BooleanFilter fullQueryBooleanFilter, SearchContext searchContext) throws Exception { BooleanQuery searchQuery = new BooleanQueryImpl(); addSearchLocalizedTerm(searchQuery, searchContext, Field.DESCRIPTION, false); addSearchLocalizedTerm(searchQuery, searchContext, Field.TITLE, false); addSearchTerm(searchQuery, searchContext, FieldNames.CONFIGURATION_MODEL_ATTRIBUTE_DESCRIPTION, false); addSearchTerm(searchQuery, searchContext, FieldNames.CONFIGURATION_MODEL_ATTRIBUTE_NAME, false); addSearchTerm(searchQuery, searchContext, FieldNames.CONFIGURATION_MODEL_FACTORY_PID, false); addSearchTerm(searchQuery, searchContext, FieldNames.CONFIGURATION_MODEL_ID, false); BooleanQuery fullBooleanQuery = new BooleanQueryImpl(); if (fullQueryBooleanFilter.hasClauses()) { fullBooleanQuery.setPreBooleanFilter(fullQueryBooleanFilter); }/* w ww . j av a 2 s . c om*/ fullBooleanQuery.add(searchQuery, BooleanClauseOccur.MUST); return fullBooleanQuery; }
From source file:com.liferay.configuration.admin.web.internal.search.ConfigurationModelIndexer.java
License:Open Source License
@Override protected Document doGetDocument(ConfigurationModel configurationModel) throws Exception { Document document = newDocument(); document.addUID(ConfigurationAdminPortletKeys.SYSTEM_SETTINGS, configurationModel.getID()); document.addKeyword(FieldNames.CONFIGURATION_MODEL_FACTORY_PID, configurationModel.getFactoryPid()); document.addKeyword(FieldNames.CONFIGURATION_MODEL_ID, configurationModel.getID()); document.addKeyword(Field.COMPANY_ID, CompanyConstants.SYSTEM); ResourceBundleLoader resourceBundleLoader = _resourceBundleLoaderProvider .getResourceBundleLoader(configurationModel.getBundleSymbolicName()); document.addLocalizedText(Field.DESCRIPTION, _translate(resourceBundleLoader, GetterUtil.getString(configurationModel.getDescription()))); document.addKeyword(Field.ENTRY_CLASS_NAME, getClassName()); AttributeDefinition[] requiredAttributeDefinitions = configurationModel .getAttributeDefinitions(ObjectClassDefinition.ALL); List<String> attributeNames = new ArrayList<>(requiredAttributeDefinitions.length); List<String> attributeDescriptions = new ArrayList<>(requiredAttributeDefinitions.length); for (AttributeDefinition attributeDefinition : requiredAttributeDefinitions) { attributeNames.add(attributeDefinition.getName()); attributeDescriptions.add(attributeDefinition.getDescription()); }//from w w w . ja va 2 s .c o m document.addKeyword(FieldNames.CONFIGURATION_MODEL_ATTRIBUTE_NAME, attributeNames.toArray(new String[attributeNames.size()])); document.addText(FieldNames.CONFIGURATION_MODEL_ATTRIBUTE_DESCRIPTION, attributeDescriptions.toArray(new String[attributeDescriptions.size()])); document.addLocalizedText(Field.TITLE, _translate(resourceBundleLoader, GetterUtil.getString(configurationModel.getName()))); return document; }
From source file:com.liferay.configuration.admin.web.internal.search.ConfigurationModelIndexer.java
License:Open Source License
@Override protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletRequest portletRequest, PortletResponse portletResponse) throws Exception { Summary summary = createSummary(document, Field.TITLE, Field.DESCRIPTION); summary.setMaxContentLength(200);/* w w w. java 2 s . c o m*/ return summary; }
From source file:com.liferay.docs.guestbook.search.GuestbookEntryKeywordQueryContributor.java
License:Open Source License
@Override public void contribute(String keywords, BooleanQuery booleanQuery, KeywordQueryContributorHelper keywordQueryContributorHelper) { SearchContext searchContext = keywordQueryContributorHelper.getSearchContext(); queryHelper.addSearchLocalizedTerm(booleanQuery, searchContext, Field.TITLE, false); queryHelper.addSearchLocalizedTerm(booleanQuery, searchContext, Field.CONTENT, false); queryHelper.addSearchLocalizedTerm(booleanQuery, searchContext, "entryEmail", false); }
From source file:com.liferay.docs.guestbook.search.GuestbookEntryModelDocumentContributor.java
License:Open Source License
@Override public void contribute(Document document, GuestbookEntry entry) { try {//from w w w. ja va 2s.c om Locale defaultLocale = PortalUtil.getSiteDefaultLocale(entry.getGroupId()); document.addDate(Field.MODIFIED_DATE, entry.getModifiedDate()); document.addText("entryEmail", entry.getEmail()); String localizedTitle = LocalizationUtil.getLocalizedName(Field.TITLE, defaultLocale.toString()); String localizedContent = LocalizationUtil.getLocalizedName(Field.CONTENT, defaultLocale.toString()); document.addText(localizedTitle, entry.getName()); document.addText(localizedContent, entry.getMessage()); long guestbookId = entry.getGuestbookId(); Guestbook guestbook = _guestbookLocalService.getGuestbook(guestbookId); String guestbookName = guestbook.getName(); String localizedGbName = LocalizationUtil.getLocalizedName(Field.NAME, defaultLocale.toString()); document.addText(localizedGbName, guestbookName); } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn("Unable to index entry " + entry.getEntryId(), pe); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.liferay.docs.guestbook.search.GuestbookEntryModelSummaryContributor.java
License:Open Source License
private Summary createSummary(Document document) { String prefix = Field.SNIPPET + StringPool.UNDERLINE; String title = document.get(prefix + Field.TITLE, Field.CONTENT); String content = document.get(prefix + Field.CONTENT, Field.CONTENT); return new Summary(title, content); }
From source file:com.liferay.docs.guestbook.search.GuestbookEntrySearchRegistrar.java
License:Open Source License
@Activate protected void activate(BundleContext bundleContext) { _serviceRegistration = modelSearchRegistrarHelper.register(GuestbookEntry.class, bundleContext, modelSearchDefinition -> { modelSearchDefinition.setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.UID, Field.SCOPE_GROUP_ID, Field.GROUP_ID); modelSearchDefinition.setDefaultSelectedLocalizedFieldNames(Field.TITLE, Field.CONTENT); modelSearchDefinition.setModelIndexWriteContributor(modelIndexWriterContributor); modelSearchDefinition.setModelSummaryContributor(modelSummaryContributor); modelSearchDefinition.setSelectAllLocales(true); });/*from w ww .jav a 2 s . c om*/ }