001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.search.lucene;
016    
017    import com.liferay.portal.kernel.cluster.Address;
018    import com.liferay.portal.kernel.exception.SystemException;
019    
020    import java.io.IOException;
021    import java.io.InputStream;
022    import java.io.OutputStream;
023    
024    import org.apache.lucene.analysis.Analyzer;
025    import org.apache.lucene.document.Document;
026    import org.apache.lucene.index.Term;
027    import org.apache.lucene.search.BooleanQuery;
028    import org.apache.lucene.search.IndexSearcher;
029    import org.apache.lucene.search.Query;
030    import org.apache.lucene.util.Version;
031    
032    /**
033     * @author Bruno Farache
034     * @author Shuyang Zhou
035     */
036    public interface LuceneHelper {
037    
038            public void addDocument(long companyId, Document document)
039                    throws IOException;
040    
041            public void addExactTerm(
042                    BooleanQuery booleanQuery, String field, String value);
043    
044            public void addNumericRangeTerm(
045                    BooleanQuery booleanQuery, String field, String startValue,
046                    String endValue);
047    
048            public void addRangeTerm(
049                    BooleanQuery booleanQuery, String field, String startValue,
050                    String endValue);
051    
052            public void addRequiredTerm(
053                    BooleanQuery booleanQuery, String field, String value, boolean like);
054    
055            public void addRequiredTerm(
056                    BooleanQuery booleanQuery, String field, String[] values, boolean like);
057    
058            public void addTerm(
059                    BooleanQuery booleanQuery, String field, String value, boolean like);
060    
061            public void addTerm(
062                    BooleanQuery booleanQuery, String field, String[] values, boolean like);
063    
064            public int countScoredFieldNames(Query query, String[] fieldNames);
065    
066            public void delete(long companyId);
067    
068            public void deleteDocuments(long companyId, Term term) throws IOException;
069    
070            public void dumpIndex(long companyId, OutputStream outputStream)
071                    throws IOException;
072    
073            public Analyzer getAnalyzer();
074    
075            public long getLastGeneration(long companyId);
076    
077            public InputStream getLoadIndexesInputStreamFromCluster(
078                            long companyId, Address bootupAddress)
079                    throws SystemException;
080    
081            public String[] getQueryTerms(Query query);
082    
083            public IndexSearcher getSearcher(long companyId, boolean readOnly)
084                    throws IOException;
085    
086            public String getSnippet(
087                            Query query, String field, String s, int maxNumFragments,
088                            int fragmentLength, String fragmentSuffix, String preTag,
089                            String postTag)
090                    throws IOException;
091    
092            public Version getVersion();
093    
094            public boolean isLoadIndexFromClusterEnabled();
095    
096            public void loadIndex(long companyId, InputStream inputStream)
097                    throws IOException;
098    
099            public Address selectBootupClusterAddress(
100                            long companyId, long localLastGeneration)
101                    throws SystemException;
102    
103            public void shutdown();
104    
105            public void startup(long companyId);
106    
107            public void updateDocument(long companyId, Term term, Document document)
108                    throws IOException;
109    
110    }