use of org.apache.lucene.index.IndexWriter in project jforum2 by rafaelsteil.
the class LuceneSettings method useRAMDirectory.
public void useRAMDirectory() throws Exception {
this.directory = new RAMDirectory();
IndexWriter writer = new IndexWriter(this.directory, this.analyzer, true);
writer.close();
}
use of org.apache.lucene.index.IndexWriter in project jforum2 by rafaelsteil.
the class LuceneSettings method createIndexDirectory.
public void createIndexDirectory(String directoryPath) throws IOException {
FSDirectory fsDir = FSDirectory.getDirectory(directoryPath);
IndexWriter writer = new IndexWriter(fsDir, this.analyzer, true);
writer.close();
}
use of org.apache.lucene.index.IndexWriter in project languagetool by languagetool-org.
the class LuceneSimpleIndexCreator method main.
public static void main(String[] args) throws IOException {
IndexWriterConfig conf = new IndexWriterConfig(new KeywordAnalyzer());
try (IndexWriter iw1 = new IndexWriter(FSDirectory.open(new File("/tmp/1grams").toPath()), conf)) {
addDoc(iw1, "the", 55);
addDoc(iw1, "nice", 10);
addDoc(iw1, "building", 1);
Document document = new Document();
document.add(new TextField("totalTokenCount", String.valueOf(3), Field.Store.YES));
iw1.addDocument(document);
}
IndexWriterConfig conf2 = new IndexWriterConfig(new KeywordAnalyzer());
try (IndexWriter iw2 = new IndexWriter(FSDirectory.open(new File("/tmp/2grams").toPath()), conf2)) {
addDoc(iw2, "the nice", 3);
addDoc(iw2, "nice building", 2);
}
IndexWriterConfig conf3 = new IndexWriterConfig(new KeywordAnalyzer());
try (IndexWriter iw3 = new IndexWriter(FSDirectory.open(new File("/tmp/3grams").toPath()), conf3)) {
addDoc(iw3, "the nice building", 1);
}
}
use of org.apache.lucene.index.IndexWriter in project lucene-skos by behas.
the class SKOSLabelFilterTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
skosAnalyzer = new SKOSAnalyzer(skosEngine, SKOSAnalyzer.ExpansionType.LABEL);
writer = new IndexWriter(directory, new IndexWriterConfig(skosAnalyzer));
}
use of org.apache.lucene.index.IndexWriter in project lucene-skos by behas.
the class SKOSURIFilterTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
skosAnalyzer = new SKOSAnalyzer(skosEngine, ExpansionType.URI);
writer = new IndexWriter(directory, new IndexWriterConfig(skosAnalyzer));
}
Aggregations