001    /**
002     * Copyright (c) 2000-2013 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 java.io.IOException;
018    import java.io.InputStream;
019    import java.io.OutputStream;
020    
021    import java.util.Collection;
022    
023    import org.apache.lucene.document.Document;
024    import org.apache.lucene.index.Term;
025    import org.apache.lucene.search.IndexSearcher;
026    import org.apache.lucene.store.Directory;
027    
028    /**
029     * @author Bruno Farache
030     * @author Shuyang Zhou
031     */
032    public interface IndexAccessor {
033    
034            public static final long DEFAULT_LAST_GENERATION = -1;
035    
036            public IndexSearcher acquireIndexSearcher() throws IOException;
037    
038            public void addDocument(Document document) throws IOException;
039    
040            public void addDocuments(Collection<Document> documents) throws IOException;
041    
042            public void close();
043    
044            public void delete();
045    
046            public void deleteDocuments(Term term) throws IOException;
047    
048            public void dumpIndex(OutputStream outputStream) throws IOException;
049    
050            public long getCompanyId();
051    
052            public long getLastGeneration();
053    
054            public Directory getLuceneDir();
055    
056            public void invalidate();
057    
058            public void loadIndex(InputStream inputStream) throws IOException;
059    
060            public void releaseIndexSearcher(IndexSearcher indexSearcher)
061                    throws IOException;
062    
063            public void updateDocument(Term term, Document document) throws IOException;
064    
065    }