001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.jsp.search.result;
029
030import org.opencms.jsp.search.config.I_CmsSearchConfigurationCommon;
031import org.opencms.jsp.search.controller.I_CmsSearchControllerMain;
032import org.opencms.search.CmsSearchException;
033import org.opencms.search.solr.CmsSolrQuery;
034
035import java.util.Collection;
036import java.util.List;
037import java.util.Map;
038
039import org.apache.solr.client.solrj.response.FacetField;
040import org.apache.solr.client.solrj.response.RangeFacet;
041import org.apache.solr.client.solrj.response.SpellCheckResponse.Suggestion;
042
043/** Interface of the JSP EL friendly wrapper for all Solr search results and the search form controller. */
044public interface I_CmsSearchResultWrapper {
045
046    /** Returns the main controller for the search form.
047     * @return The main controller for the search form.
048     */
049    I_CmsSearchControllerMain getController();
050
051    /** Returns the "Did you mean ...?" suggestion - if did you mean is enabled.
052     * @return The "Did you mean ...?" suggestion - if did you mean is enabled.
053     */
054    String getDidYouMeanCollated();
055
056    /** Returns the suggestion of "Did you mean ...?" for the complete query - if did you mean is enabled.
057     * @return The suggestion of "Did you mean ...?" for the complete query - if did you mean is enabled.
058     */
059    Suggestion getDidYouMeanSuggestion();
060
061    /** Returns the empty search state parameters. Use the function to generate just part of the state parameters, instead of manipulating the current state.
062     * @return The empty search state parameters.
063     */
064    I_CmsSearchStateParameters getEmptyStateParameters();
065
066    /** Returns the last index of the documents displayed.
067     * @return The last index of the documents displayed.
068     */
069    int getEnd();
070
071    /** Returns the search exception if search fails.
072     * @return The exception thrown by Solr, or <code>null</code> if the search succeeds. */
073    CmsSearchException getException();
074
075    /** Returns the result of the query facet, i.e., the map from queries to the number of hits.
076     * @return The result of the query facet, i.e., the map from queries to the number of hits.
077     */
078    Map<String, Integer> getFacetQuery();
079
080    /** Returns the map for field facet names to the search result part for that field facet.
081     * @return The map for field facet names to the search result part for that field facet.
082     */
083    Map<String, FacetField> getFieldFacet();
084
085    /** Returns the collection of the search result parts for the field facets.
086     * @return The collection of the search result parts for the field facets.
087     */
088    Collection<FacetField> getFieldFacets();
089
090    /** Returns the query object as send to Solr.
091     * @return The query object as send to Solr.
092     */
093    CmsSolrQuery getFinalQuery();
094
095    /** Returns the map from the document ids to the corresponding highlighting results (as map from the highlighted field to the highlighted snippets).
096     * @return The map from the document ids to the corresponding highlighting results (as map from the highlighted field to the highlighted snippets).
097     */
098    Map<String, Map<String, List<String>>> getHighlighting();
099
100    /** Returns the maximal score of the found documents.
101     * @return The maximal score of the found documents.
102     */
103    Float getMaxScore();
104
105    /** Returns for the specified facet (key) the selected facet entries that are not part of the returned facet entries are provided (value).
106     * @return For the specified facet (key) the selected facet entries that are not part of the returned facet entries are provided (value).
107     */
108    Map<String, List<String>> getMissingSelectedFieldFacetEntries();
109
110    /** Returns the selected facet entries that are not part of the returned facet entries are provided (value).
111     * @return The selected facet entries that are not part of the returned facet entries are provided (value).
112     */
113    List<String> getMissingSelectedQueryFacetEntries();
114
115    /** Returns for the specified facet (key) the selected facet entries that are not part of the returned facet entries are provided (value).
116     * @return For the specified facet (key) the selected facet entries that are not part of the returned facet entries are provided (value).
117     */
118    Map<String, List<String>> getMissingSelectedRangeFacetEntries();
119
120    /** Returns the number of resources that where found.
121     * @return The number of resources that where found.
122     */
123    long getNumFound();
124
125    /**
126     * Returns the number of maximally returned results, this is the minimum of the number of found results {@link #getNumFound()}
127     * and the number of results maximally processed {@link I_CmsSearchConfigurationCommon#getMaxReturnedResults()}
128     * @return the number of maximally returned results.
129     */
130    long getNumMaxReturned();
131
132    /** Returns the number of pages necessary to show all search results.
133     * @return The number of pages necessary to show all search results.
134     */
135    int getNumPages();
136
137    /** Returns the number of the fist page that should be shown in a "Google"-like page navigation.
138     * @return The number of the fist page that should be shown in a "Google"-like page navigation.
139     */
140    int getPageNavFirst();
141
142    /** Returns the number of the last page that should be shown in a "Google"-like page navigation.
143     * @return The number of the last page that should be shown in a "Google"-like page navigation.
144     */
145    int getPageNavLast();
146
147    /** Returns the map for range facet names to the search result part for that range facet.
148     * @return The map for range facet names to the search result part for that range facet.
149     */
150    @SuppressWarnings("rawtypes")
151    Map<String, RangeFacet> getRangeFacet();
152
153    /** Returns the collection of the search result parts for the range facets.
154     * @return The collection of the search result parts for the range facets.
155     */
156    @SuppressWarnings("rawtypes")
157    Collection<RangeFacet> getRangeFacets();
158
159    /** Returns the collection of the search results that are returned by Solr.
160     * @return The collection of the search results that are returned by Solr.
161     */
162    Collection<I_CmsSearchResourceBean> getSearchResults();
163
164    /** Returns the index (starting at 1) of the first result that is returned for displaying.
165     * @return The index (starting at 1) of the first result that is returned for displaying.
166     */
167    Long getStart();
168
169    /** Returns the current search state parameters.
170     * @return The current search state parameters.
171     */
172    I_CmsSearchStateParameters getStateParameters();
173}