001/* 002 * Copyright 2016 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.cms.search; 017 018import java.util.Map; 019import java.util.Optional; 020 021import org.ametys.plugins.repository.AmetysObject; 022import org.ametys.plugins.repository.AmetysObjectIterable; 023 024/** 025 * Interface representing the results of a search. 026 * @param <A> the actual type of {@link AmetysObject}s. 027 */ 028public interface SearchResults<A extends AmetysObject> 029{ 030 /** 031 * Get the {@link Iterable} of the search results. 032 * @return A {@link SearchResultsIterable} on the {@link SearchResult}. 033 */ 034 SearchResultsIterable<SearchResult<A>> getResults(); 035 036 /** 037 * Get the {@link AmetysObject} results 038 * @return An {@link AmetysObjectIterable} on the results. 039 */ 040 AmetysObjectIterable<A> getObjects(); 041 042 /** 043 * Get the result IDs. 044 * @return An {@link Iterable} on the content IDs. 045 */ 046 Iterable<String> getObjectIds(); 047 048 /** 049 * Get the facet results as a Map, indexed by faceted criterion ID.<br> 050 * The Map values are represented by a Map of value -> result count. 051 * @return the facet results. 052 */ 053 Map<String, Map<String, Integer>> getFacetResults(); 054 055 /** 056 * Get the total number of search results. 057 * @return the total number of results matching the search (whatever the limit): the iterable 058 * may contain less objects than this count. 059 */ 060 long getTotalCount(); 061 062 /** 063 * Get the maximum score of all the results. 064 * @return the maximum score of all the results. 065 */ 066 float getMaxScore(); 067 068 /** 069 * Gets the response debug map if available 070 * @return the response debug map if available 071 */ 072 Optional<Map<String, Object>> getDebugMap(); 073}