protected BaseModelSearchResult<JournalArticle> searchJournalArticles( SearchContext searchContext) throws PortalException { Indexer<JournalArticle> indexer = IndexerRegistryUtil.nullSafeGetIndexer(JournalArticle.class); for (int i = 0; i < 10; i++) { Hits hits = indexer.search( searchContext, JournalUtil.SELECTED_FIELD_NAMES); List<JournalArticle> articles = _journalHelper.getArticles(hits); if (articles != null) { return new BaseModelSearchResult<>(articles, hits.getLength()); } } throw new SearchException( "Unable to fix the search index after 10 attempts"); }
@Override public BaseModelSearchResult<DDMFormInstanceRecord> searchFormInstanceRecords(SearchContext searchContext) { try { Indexer<DDMFormInstanceRecord> indexer = getDDMFormInstanceRecordIndexer(); Hits hits = indexer.search(searchContext, _SELECTED_FIELD_NAMES); List<DDMFormInstanceRecord> formInstanceRecords = getFormInstanceRecords(hits); return new BaseModelSearchResult<>( formInstanceRecords, hits.getLength()); } catch (Exception e) { throw new SystemException(e); } }
public static BaseModelSearchResult<AssetEntry> getAssetEntries( AssetEntryQuery assetEntryQuery, Layout layout, PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone, long companyId, long scopeGroupId, long userId, Map<String, Serializable> attributes, int start, int end) throws Exception { if (isSearchWithIndex(portletName, assetEntryQuery)) { return _assetHelper.searchAssetEntries( assetEntryQuery, getAssetCategoryIds(portletPreferences), getAssetTagNames(portletPreferences), attributes, companyId, assetEntryQuery.getKeywords(), layout, locale, scopeGroupId, timeZone, userId, start, end); } int total = _assetEntryService.getEntriesCount(assetEntryQuery); assetEntryQuery.setEnd(end); assetEntryQuery.setStart(start); List<AssetEntry> results = _assetEntryService.getEntries( assetEntryQuery); return new BaseModelSearchResult<>(results, total); }
@Override public BaseModelSearchResult<AssetEntry> getAssetEntries( AssetEntryQuery assetEntryQuery, Layout layout, PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone, long companyId, long scopeGroupId, long userId, Map<String, Serializable> attributes, int start, int end) throws Exception { if (_isSearchWithIndex(portletName, assetEntryQuery)) { return _assetHelper.searchAssetEntries( assetEntryQuery, getAssetCategoryIds(portletPreferences), getAssetTagNames(portletPreferences), attributes, companyId, assetEntryQuery.getKeywords(), layout, locale, scopeGroupId, timeZone, userId, start, end); } int total = _assetEntryService.getEntriesCount(assetEntryQuery); assetEntryQuery.setEnd(end); assetEntryQuery.setStart(start); List<AssetEntry> results = _assetEntryService.getEntries( assetEntryQuery); return new BaseModelSearchResult<>(results, total); }