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.search.lucene;
016    
017    import com.liferay.portal.kernel.cluster.Address;
018    import com.liferay.portal.kernel.search.BooleanClauseOccur;
019    
020    import java.io.IOException;
021    import java.io.InputStream;
022    import java.io.OutputStream;
023    
024    import java.util.Set;
025    
026    import org.apache.lucene.analysis.Analyzer;
027    import org.apache.lucene.document.Document;
028    import org.apache.lucene.index.Term;
029    import org.apache.lucene.search.BooleanQuery;
030    import org.apache.lucene.search.IndexSearcher;
031    import org.apache.lucene.search.Query;
032    import org.apache.lucene.search.highlight.Formatter;
033    import org.apache.lucene.util.Version;
034    
035    /**
036     * @author Bruno Farache
037     * @author Shuyang Zhou
038     * @author Andrea Di Giorgi
039     */
040    public interface LuceneHelper {
041    
042            public void addDocument(long companyId, Document document)
043                    throws IOException;
044    
045            public void addExactTerm(
046                    BooleanQuery booleanQuery, String field, String value);
047    
048            public void addNumericRangeTerm(
049                    BooleanQuery booleanQuery, String field, Integer startValue,
050                    Integer endValue);
051    
052            public void addNumericRangeTerm(
053                    BooleanQuery booleanQuery, String field, Long startValue,
054                    Long endValue);
055    
056            /**
057             * @deprecated As of 6.2.0, replaced by {@link
058             *             #addNumericRangeTerm(BooleanQuery, String, Long, Long)}
059             */
060            @Deprecated
061            public void addNumericRangeTerm(
062                    BooleanQuery booleanQuery, String field, String startValue,
063                    String endValue);
064    
065            public void addRangeTerm(
066                    BooleanQuery booleanQuery, String field, String startValue,
067                    String endValue);
068    
069            public void addRequiredTerm(
070                    BooleanQuery booleanQuery, String field, String value, boolean like);
071    
072            public void addRequiredTerm(
073                    BooleanQuery booleanQuery, String field, String[] values, boolean like);
074    
075            public void addTerm(
076                    BooleanQuery booleanQuery, String field, String value, boolean like);
077    
078            public void addTerm(
079                    BooleanQuery booleanQuery, String field, String value, boolean like,
080                    BooleanClauseOccur booleanClauseOccur);
081    
082            public void addTerm(
083                    BooleanQuery booleanQuery, String field, String[] values, boolean like);
084    
085            /**
086             * @deprecated As of 7.0.0, replaced by {@link #releaseIndexSearcher(long,
087             *             IndexSearcher)}
088             */
089            @Deprecated
090            public void cleanUp(IndexSearcher indexSearcher);
091    
092            public int countScoredFieldNames(Query query, String[] fieldNames);
093    
094            public void delete(long companyId);
095    
096            public void deleteDocuments(long companyId, Term term) throws IOException;
097    
098            public void dumpIndex(long companyId, OutputStream outputStream)
099                    throws IOException;
100    
101            public Analyzer getAnalyzer();
102    
103            public IndexAccessor getIndexAccessor(long companyId);
104    
105            public IndexSearcher getIndexSearcher(long companyId) throws IOException;
106    
107            public long getLastGeneration(long companyId);
108    
109            public InputStream getLoadIndexesInputStreamFromCluster(
110                    long companyId, Address bootupAddress);
111    
112            public Set<String> getQueryTerms(Query query);
113    
114            /**
115             * @deprecated As of 7.0.0, replaced by {@link #getIndexSearcher(long)}
116             */
117            @Deprecated
118            public IndexSearcher getSearcher(long companyId, boolean readOnly)
119                    throws IOException;
120    
121            public String getSnippet(
122                            Query query, String field, String s, int maxNumFragments,
123                            int fragmentLength, String fragmentSuffix, Formatter formatter)
124                    throws IOException;
125    
126            public Version getVersion();
127    
128            public boolean isLoadIndexFromClusterEnabled();
129    
130            public void loadIndex(long companyId, InputStream inputStream)
131                    throws IOException;
132    
133            public void loadIndexesFromCluster(long companyId);
134    
135            public void releaseIndexSearcher(
136                            long companyId, IndexSearcher indexSearcher)
137                    throws IOException;
138    
139            public void shutdown();
140    
141            public void shutdown(long companyId);
142    
143            public void startup(long companyId);
144    
145            public void updateDocument(long companyId, Term term, Document document)
146                    throws IOException;
147    
148    }