001    /**
002     * Copyright (c) 2000-2011 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 java.io.IOException;
018    
019    import org.apache.lucene.analysis.Analyzer;
020    import org.apache.lucene.document.Document;
021    import org.apache.lucene.index.Term;
022    import org.apache.lucene.queryParser.ParseException;
023    import org.apache.lucene.search.BooleanQuery;
024    import org.apache.lucene.search.IndexSearcher;
025    import org.apache.lucene.search.Query;
026    import org.apache.lucene.util.Version;
027    
028    /**
029     * @author Bruno Farache
030     */
031    public interface LuceneHelper {
032    
033            public void addDocument(long companyId, Document document)
034                    throws IOException;
035    
036            public void addExactTerm(
037                    BooleanQuery booleanQuery, String field, String value);
038    
039            public void addRequiredTerm(
040                    BooleanQuery booleanQuery, String field, String value, boolean like);
041    
042            public void addTerm(
043                            BooleanQuery booleanQuery, String field, String value, boolean like)
044                    throws ParseException;
045    
046            public void delete(long companyId);
047    
048            public void deleteDocuments(long companyId, Term term) throws IOException;
049    
050            public Analyzer getAnalyzer();
051    
052            public String[] getQueryTerms(Query query);
053    
054            public IndexSearcher getSearcher(long companyId, boolean readOnly)
055                    throws IOException;
056    
057            public String getSnippet(
058                            Query query, String field, String s, int maxNumFragments,
059                            int fragmentLength, String fragmentSuffix, String preTag,
060                            String postTag)
061                    throws IOException;
062    
063            public Version getVersion();
064    
065            public void shutdown();
066    
067            public void updateDocument(long companyId, Term term, Document document)
068                    throws IOException;
069    
070    }