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 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    }