public void recordHits(Hits hits, long groupId, boolean privateLayout, int start, int end) throws Exception { // This can later be optimized according to LEP-915. List<Document> docs = new ArrayList<Document>(); List<Float> scores = new ArrayList<Float>(); Document[] docsArray = hits.getDocs(); for (int i = 0; i < docsArray.length; i++) { Document doc = hits.doc(i); String articleId = doc.get(Field.ARTICLE_ID); long articleGroupId = GetterUtil.getLong(doc.get(Field.GROUP_ID)); int layoutIdsCount = JournalContentSearchLocalServiceUtil.getLayoutIdsCount(groupId, privateLayout, articleId); if ((layoutIdsCount > 0) || (!isShowListed() && (articleGroupId == groupId))) { docs.add(hits.doc(i)); scores.add(hits.score(i)); } } int length = docs.size(); hits.setLength(length); if (end > length) { end = length; } docs = docs.subList(start, end); scores = scores.subList(start, end); hits.setDocs(docs.toArray(new Document[docs.size()])); hits.setScores(ArrayUtil.toFloatArray(scores)); hits.setSearchTime((float) (System.currentTimeMillis() - hits.getStart()) / Time.SECOND); }