001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.search;
016    
017    import com.liferay.portal.kernel.util.StringPool;
018    
019    import java.util.Collections;
020    import java.util.List;
021    import java.util.Map;
022    
023    /**
024     * @author Marcellus Tavares
025     * @author Carlos Sierra Andr??s
026     */
027    public class DummyIndexSearcher implements IndexSearcher {
028    
029            @Override
030            public Hits search(SearchContext searchContext, Query query) {
031                    return _getHits();
032            }
033    
034            /**
035             * @deprecated As of 7.0.0, replaced by {@link #search(SearchContext,
036             *             Query)}
037             */
038            @Deprecated
039            @Override
040            public Hits search(
041                    String searchEngineId, long companyId, Query query, Sort[] sort,
042                    int start, int end) {
043    
044                    return _getHits();
045            }
046    
047            @Override
048            public String spellCheckKeywords(SearchContext searchContext) {
049                    return StringPool.BLANK;
050            }
051    
052            @Override
053            public Map<String, List<String>> spellCheckKeywords(
054                    SearchContext searchContext, int max) {
055    
056                    return Collections.emptyMap();
057            }
058    
059            @Override
060            public String[] suggestKeywordQueries(
061                    SearchContext searchContext, int max) {
062    
063                    return new String[0];
064            }
065    
066            private Hits _getHits() {
067                    Hits hits = new HitsImpl();
068    
069                    hits.setCollatedSpellCheckResult(StringPool.BLANK);
070                    hits.setDocs(new Document[0]);
071                    hits.setLength(0);
072                    hits.setQuery(new StringQueryImpl(StringPool.BLANK));
073                    hits.setQuerySuggestions(new String[0]);
074                    hits.setQueryTerms(new String[0]);
075                    hits.setLength(0);
076                    hits.setScores(new float[0]);
077                    hits.setSearchTime(0);
078                    hits.setSnippets(new String[0]);
079                    hits.setSpellCheckResults(_spellCheckResults);
080                    hits.setStart(0);
081    
082                    return hits;
083            }
084    
085            private static final Map<String, List<String>> _spellCheckResults =
086                    Collections.emptyMap();
087    
088    }