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;
019
020import org.ametys.plugins.repository.AmetysObject;
021import org.ametys.plugins.repository.AmetysObjectIterable;
022
023/**
024 * Interface representing the results of a search.
025 * @param <A> the actual type of {@link AmetysObject}s. 
026 */
027public interface SearchResults<A extends AmetysObject>
028{
029    /**
030     * Get the {@link Iterable} of the search results.
031     * @return A {@link SearchResultsIterable} on the {@link SearchResult}.
032     */
033    SearchResultsIterable<SearchResult<A>> getResults();
034    
035    /**
036     * Get the {@link AmetysObject} results
037     * @return An {@link AmetysObjectIterable} on the results.
038     */
039    AmetysObjectIterable<A> getObjects();
040    
041    /**
042     * Get the result IDs.
043     * @return An {@link Iterable} on the content IDs.
044     */
045    Iterable<String> getObjectIds();
046    
047    /**
048     * Get the facet results as a Map, indexed by faceted criterion ID.<br>
049     * The Map values are represented by a Map of value -&gt; result count.
050     * @return the facet results.
051     */
052    Map<String, Map<String, Integer>> getFacetResults();
053    
054    /**
055     * Get the total number of search results.
056     * @return the total number of results matching the search (whatever the limit): the iterable
057     * may contain less objects than this count.
058     */
059    long getTotalCount();
060    
061    /**
062     * Get the maximum score of all the results.
063     * @return the maximum score of all the results.
064     */
065    float getMaxScore();
066}