public static Hits search( SearchContext searchContext, AssetEntryQuery assetEntryQuery, int start, int end) throws Exception { AssetSearcher assetSearcher = getAssetSearcher(searchContext, assetEntryQuery, start, end); return assetSearcher.search(searchContext); }
public static BaseModelSearchResult<AssetEntry> searchAssetEntries( SearchContext searchContext, AssetEntryQuery assetEntryQuery, int start, int end) throws Exception { AssetSearcher assetSearcher = getAssetSearcher(searchContext, assetEntryQuery, start, end); Hits hits = assetSearcher.search(searchContext); List<AssetEntry> assetEntries = getAssetEntries(hits); return new BaseModelSearchResult<>(assetEntries, hits.getLength()); }
protected static AssetSearcher getAssetSearcher( SearchContext searchContext, AssetEntryQuery assetEntryQuery, int start, int end) throws Exception { Indexer<?> searcher = AssetSearcher.getInstance(); AssetSearcher assetSearcher = (AssetSearcher) searcher; assetSearcher.setAssetEntryQuery(assetEntryQuery); Layout layout = assetEntryQuery.getLayout(); if (layout != null) { searchContext.setAttribute(Field.LAYOUT_UUID, layout.getUuid()); } String ddmStructureFieldName = (String) assetEntryQuery.getAttribute("ddmStructureFieldName"); Serializable ddmStructureFieldValue = assetEntryQuery.getAttribute("ddmStructureFieldValue"); if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) { searchContext.setAttribute("ddmStructureFieldName", ddmStructureFieldName); searchContext.setAttribute("ddmStructureFieldValue", ddmStructureFieldValue); } String paginationType = GetterUtil.getString(assetEntryQuery.getPaginationType(), "more"); if (!paginationType.equals("none") && !paginationType.equals("simple")) { searchContext.setAttribute("paginationType", paginationType); } searchContext.setClassTypeIds(assetEntryQuery.getClassTypeIds()); searchContext.setEnd(end); searchContext.setGroupIds(assetEntryQuery.getGroupIds()); if (Validator.isNotNull(assetEntryQuery.getKeywords())) { searchContext.setLike(true); } searchContext.setSorts(getSorts(assetEntryQuery, searchContext.getLocale())); searchContext.setStart(start); return assetSearcher; }