@@ -0,0 +1,2855 @@
+package ka.kaznu.lucene.index;%0A%0Aimport org.apache.lucene.analysis.Analyzer;%0Aimport org.apache.lucene.analysis.ru.RussianAnalyzer;%0Aimport org.apache.lucene.document.Document;%0Aimport org.apache.lucene.index.DirectoryReader;%0Aimport org.apache.lucene.index.IndexReader;%0Aimport org.apache.lucene.index.IndexWriter;%0Aimport org.apache.lucene.index.IndexWriterConfig;%0Aimport org.apache.lucene.store.Directory;%0Aimport org.apache.lucene.store.FSDirectory;%0A%0Aimport java.io.IOException;%0Aimport java.nio.file.Paths;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Default Indexer that we will use in tutorial%0A * Be default it will use RussianAnalyzer to analyze text%0A */%0Apublic class MessageIndexer %7B%0A    private final String pathToIndexFolder;%0A%0A    public MessageIndexer(String pathToIndexFolder) %7B%0A        this.pathToIndexFolder = pathToIndexFolder;%0A    %7D%0A%0A    /**%0A     * Indexing documents using provided Analyzer%0A     *%0A     * @param create to decide create new or append to previous one%0A     * @throws IOException%0A     */%0A    public void index(final Boolean create, List%3CDocument%3E documents, Analyzer analyzer) throws IOException %7B%0A        final Directory dir = FSDirectory.open(Paths.get(pathToIndexFolder));%0A        final IndexWriterConfig iwc = new IndexWriterConfig(analyzer);%0A        if (create) %7B%0A            // Create a new index in the directory, removing any%0A            // previously indexed documents:%0A            iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE);%0A        %7D%0A        else %7B%0A            // Add new documents to an existing index:%0A            iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);%0A        %7D%0A%0A        final IndexWriter w = new IndexWriter(dir, iwc);%0A        w.addDocuments(documents);%0A        w.close();%0A    %7D%0A%0A    /**%0A     * Indexing documents with RussianAnalyzer as analyzer%0A     *%0A     * @param create to decide create new or append to previous one%0A     * @throws IOException%0A     */%0A    public void index(final Boolean create, List%3CDocument%3E documents) throws IOException %7B%0A        final Analyzer analyzer = new RussianAnalyzer();%0A        index(create, documents, analyzer);%0A    %7D%0A%0A    /**%0A     * Indexing one document%0A     *%0A     * @param create to decide create new or append to previous one%0A     * @throws IOException%0A     */%0A    public void index(final Boolean create, Document document) throws IOException %7B%0A        final List%3CDocument%3E oneDocumentList = new ArrayList%3C%3E();%0A        oneDocumentList.add(document);%0A        index(create, oneDocumentList);%0A    %7D%0A%0A    /**%0A     * Get IndexReader by using pathToIndexFolder%0A     *%0A     * @return IndexReader or IOException if any%0A     * @throws IOException%0A     */%0A    public IndexReader readIndex() throws IOException %7B%0A        final Directory dir = FSDirectory.open(Paths.get(pathToIndexFolder));%0A        return DirectoryReader.open(dir);%0A    %7D%0A%7D%0A

Add MessageIndexer that we will use for read/write indexes