List<Record> getRandomFolders(int qty, int counter) { MetadataSchema folderSchema = getMetadataSchemasManager().getSchemaTypes(COLLECTION).getSchema("folder_default"); Metadata categoryMetadata = folderSchema.getMetadata(Folder.CATEGORY_ENTERED); SearchServices searchServices = getSearchServices(); String categoryId = level1And2CategoryIds.get(counter % level1And2CategoryIds.size()); LogicalSearchCondition condition = from(folderSchema).where(categoryMetadata).isEqualTo(categoryId); LogicalSearchQuery query = new LogicalSearchQuery(condition); query.setNumberOfRows(qty); return searchServices.search(query); }
void doSearch(HttpServletRequest request, HttpServletResponse response, int serviceCall) throws ServletException, IOException { int qty = getRequiredIntegerParameter(request, QUANTITY_PARAMETER); MetadataSchema folderSchema = getMetadataSchemasManager().getSchemaTypes(COLLECTION).getSchema("folder_default"); Metadata categoryMetadata = folderSchema.getMetadata("category"); SearchServices searchServices = getSearchServices(); String categoryId = level1And2CategoryIds.get(serviceCall % level1And2CategoryIds.size()); LogicalSearchCondition condition = from(folderSchema).where(categoryMetadata).isEqualTo(categoryId); LogicalSearchQuery query = new LogicalSearchQuery(condition); query.setReturnedMetadatas(ReturnedMetadatasFilter.idVersionSchemaTitle()); query.setNumberOfRows(qty); searchServices.search(query); }
public void sort(MetadataVO[] propertyId, boolean[] ascending) { query.clearSort(); for (int i = 0; i < propertyId.length; i++) { Metadata metadata; MetadataSchema schema = query.getSchemaCondition(); MetadataVO metadataVO = propertyId[i]; metadata = schema.getMetadata(metadataVO.getCode()); if (ascending[i]) { query = query.sortAsc(metadata); } else { query = query.sortDesc(metadata); } } }
public List<SearchResultVO> listSearchResultVOs(int startIndex, int numberOfItems) { List<SearchResultVO> results = new ArrayList<>(numberOfItems); SPEQueryResponse response = searchServices.query(query.setStartRow(startIndex).setNumberOfRows(numberOfItems)); List<Record> records = response.getRecords(); Map<String, Map<String, List<String>>> highlights = response.getHighlights(); for (int i = 0; i < records.size(); i++) { RecordVO recordVO = voBuilder.build(records.get(i), VIEW_MODE.TABLE, sessionContext); SearchResultVO searchResultVO = new SearchResultVO(recordVO, highlights.get(recordVO.getId())); results.add(searchResultVO); cache.put(startIndex + i, searchResultVO); } return results; }