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.List; 019import java.util.Map; 020import java.util.Optional; 021 022import org.ametys.plugins.repository.AmetysObject; 023import org.ametys.plugins.repository.AmetysObjectIterable; 024 025/** 026 * Interface representing the results of a search. 027 * @param <A> the actual type of {@link AmetysObject}s. 028 */ 029public interface SearchResults<A extends AmetysObject> 030{ 031 /** 032 * Get the {@link Iterable} of the search results. 033 * @return A {@link SearchResultsIterable} on the {@link SearchResult}. 034 */ 035 SearchResultsIterable<SearchResult<A>> getResults(); 036 037 /** 038 * Get the {@link AmetysObject} results 039 * @return An {@link AmetysObjectIterable} on the results. 040 */ 041 AmetysObjectIterable<A> getObjects(); 042 043 /** 044 * Get the result IDs. 045 * @return An {@link Iterable} on the content IDs. 046 */ 047 Iterable<String> getObjectIds(); 048 049 /** 050 * Get the facet results as a Map, indexed by faceted criterion ID.<br> 051 * The Map values are represented by a Map of value -> result count. 052 * @return the facet results. 053 */ 054 Map<String, Map<String, Integer>> getFacetResults(); 055 056 /** 057 * Get the highlighting result as a Map, indexed by object ID.<br> 058 * The Map values are a Map indexed by Sol'R field name containing 059 * a list of snippet with the text highlighted 060 * @return the highlight results or null if highlighting was not enabled 061 */ 062 Map<String, Map<String, List<String>>> getHighlighting(); 063 064 /** 065 * Get the total number of search results. 066 * @return the total number of results matching the search (whatever the limit): the iterable 067 * may contain less objects than this count. 068 */ 069 long getTotalCount(); 070 071 /** 072 * Get the maximum score of all the results. 073 * @return the maximum score of all the results. 074 */ 075 float getMaxScore(); 076 077 /** 078 * Gets the response debug map if available 079 * @return the response debug map if available 080 */ 081 Optional<Map<String, Object>> getDebugMap(); 082}