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.search.lucene;
016    
017    import com.liferay.portal.kernel.cluster.Address;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.search.BooleanClauseOccur;
020    
021    import java.io.IOException;
022    import java.io.InputStream;
023    import java.io.OutputStream;
024    
025    import java.util.Set;
026    
027    import org.apache.lucene.analysis.Analyzer;
028    import org.apache.lucene.document.Document;
029    import org.apache.lucene.index.Term;
030    import org.apache.lucene.search.BooleanQuery;
031    import org.apache.lucene.search.IndexSearcher;
032    import org.apache.lucene.search.Query;
033    import org.apache.lucene.search.highlight.Formatter;
034    import org.apache.lucene.util.Version;
035    
036    /**
037     * @author Bruno Farache
038     * @author Shuyang Zhou
039     * @author Andrea Di Giorgi
040     */
041    public interface LuceneHelper {
042    
043            public void addDocument(long companyId, Document document)
044                    throws IOException;
045    
046            public void addExactTerm(
047                    BooleanQuery booleanQuery, String field, String value);
048    
049            public void addNumericRangeTerm(
050                    BooleanQuery booleanQuery, String field, Integer startValue,
051                    Integer endValue);
052    
053            public void addNumericRangeTerm(
054                    BooleanQuery booleanQuery, String field, Long startValue,
055                    Long endValue);
056    
057            /**
058             * @deprecated As of 6.2.0, replaced by {@link
059             *             #addNumericRangeTerm(BooleanQuery, String, Long, Long)}
060             */
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                    throws SystemException;
112    
113            public Set<String> getQueryTerms(Query query);
114    
115            /**
116             * @deprecated As of 7.0.0, replaced by {@link #getIndexSearcher(long)}
117             */
118            @Deprecated
119            public IndexSearcher getSearcher(long companyId, boolean readOnly)
120                    throws IOException;
121    
122            public String getSnippet(
123                            Query query, String field, String s, int maxNumFragments,
124                            int fragmentLength, String fragmentSuffix, Formatter formatter)
125                    throws IOException;
126    
127            public Version getVersion();
128    
129            public boolean isLoadIndexFromClusterEnabled();
130    
131            public void loadIndex(long companyId, InputStream inputStream)
132                    throws IOException;
133    
134            public void loadIndexesFromCluster(long companyId) throws SystemException;
135    
136            public void releaseIndexSearcher(
137                            long companyId, IndexSearcher indexSearcher)
138                    throws IOException;
139    
140            public void shutdown();
141    
142            public void shutdown(long companyId);
143    
144            public void startup(long companyId);
145    
146            public void updateDocument(long companyId, Term term, Document document)
147                    throws IOException;
148    
149    }