001    /**
002     * Copyright (c) 2000-2013 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            @Override
035            public Hits search(
036                    String searchEngineId, long companyId, Query query, Sort[] sort,
037                    int start, int end) {
038    
039                    return _getHits();
040            }
041    
042            @Override
043            public String spellCheckKeywords(SearchContext searchContext) {
044                    return StringPool.BLANK;
045            }
046    
047            @Override
048            public Map<String, List<String>> spellCheckKeywords(
049                    SearchContext searchContext, int max) {
050    
051                    return Collections.emptyMap();
052            }
053    
054            @Override
055            public String[] suggestKeywordQueries(
056                    SearchContext searchContext, int max) {
057    
058                    return new String[0];
059            }
060    
061            private Hits _getHits() {
062                    Hits hits = new HitsImpl();
063    
064                    hits.setCollatedSpellCheckResult(StringPool.BLANK);
065                    hits.setDocs(new Document[0]);
066                    hits.setLength(0);
067                    hits.setQuery(new StringQueryImpl(StringPool.BLANK));
068                    hits.setQuerySuggestions(new String[0]);
069                    hits.setQueryTerms(new String[0]);
070                    hits.setLength(0);
071                    hits.setScores(new float[0]);
072                    hits.setSearchTime(0);
073                    hits.setSnippets(new String[0]);
074                    hits.setSpellCheckResults(_spellCheckResults);
075                    hits.setStart(0);
076    
077                    return hits;
078            }
079    
080            private static Map<String, List<String>> _spellCheckResults =
081                    Collections.emptyMap();
082    
083    }