List of usage examples for com.liferay.portal.kernel.search Indexer search
public Hits search(SearchContext searchContext, String... selectedFieldNames) throws SearchException;
From source file:com.liferay.dynamic.data.lists.service.impl.DDLRecordLocalServiceImpl.java
License:Open Source License
/** * Searches for records documents indexed by the search engine. * * @param searchContext the search context to be applied for searching * documents. For more information, see <code>SearchContext</code> * in the <code>portal-kernel</code> module. * @return BaseModelSearchResult containing the list of records that matched * the search criteria//from w w w . ja v a 2s . c o m */ @Override public BaseModelSearchResult<DDLRecord> searchDDLRecords(SearchContext searchContext) { try { Indexer<DDLRecord> indexer = getDDLRecordIndexer(); Hits hits = indexer.search(searchContext, DDL.SELECTED_FIELD_NAMES); List<DDLRecord> records = getRecords(hits); return new BaseModelSearchResult<>(records, hits.getLength()); } catch (Exception e) { throw new SystemException(e); } }
From source file:com.liferay.dynamic.data.mapping.service.impl.DDMFormInstanceRecordLocalServiceImpl.java
License:Open Source License
@Override public BaseModelSearchResult<DDMFormInstanceRecord> searchFormInstanceRecords(SearchContext searchContext) { try {// ww w. j a v a 2 s. c om 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); } }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
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 = JournalUtil.getArticles(hits); if (articles != null) { return new BaseModelSearchResult<>(articles, hits.getLength()); }//from ww w . j ava2s . c o m } throw new SearchException("Unable to fix the search index after 10 attempts"); }