Created
September 9, 2012 22:35
-
-
Save michail-nikolaev/3687728 to your computer and use it in GitHub Desktop.
Java - Lucene in RAM - withpit tokenizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RAMDirectory ramDirectory = new RAMDirectory(); | |
Analyzer analyzer = new SimpleAnalyzer(Version.LUCENE_36); | |
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_36, analyzer); | |
int processed = 0; | |
try { | |
IndexWriter writer = new IndexWriter(ramDirectory, config); | |
writer.commit(); | |
...... | |
IndexReader reader = IndexReader.open(ramDirectory); | |
IndexSearcher searcher = new IndexSearcher(reader); | |
TopDocs docs = searcher.search(new FuzzyQuery(new Term(ALIAS, alias), 0.8f), 10); | |
if (docs.totalHits > 0) { | |
for (int q = 0; q < docs.scoreDocs.length; q++) { | |
String synonym = searcher.doc(docs.scoreDocs[q].doc).get(ALIAS); | |
...... | |
Document document = new Document(); | |
document.add(new Field(ALIAS, alias, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); | |
writer.addDocument(document); | |
writer.commit(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment