Search in sources :

Example 1 with OLucenePerFieldAnalyzerWrapper

use of com.orientechnologies.lucene.analyzer.OLucenePerFieldAnalyzerWrapper in project orientdb by orientechnologies.

the class LuceneVsLuceneTest method init.

@Before
public void init() {
    InputStream stream = ClassLoader.getSystemResourceAsStream("testLuceneIndex.sql");
    db.command(new OCommandScript("sql", getScriptFromStream(stream))).execute();
    OSchema schema = db.getMetadata().getSchema();
    OFileUtils.deleteRecursively(getPath().getAbsoluteFile());
    try {
        Directory dir = getDirectory();
        analyzer = new OLucenePerFieldAnalyzerWrapper(new StandardAnalyzer());
        analyzer.add("title", new StandardAnalyzer()).add("Song.title", new StandardAnalyzer());
        IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
        iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
        indexWriter = new IndexWriter(dir, iwc);
    } catch (IOException e) {
        e.printStackTrace();
    }
    db.command(new OCommandSQL("create index Song.title on Song (title) FULLTEXT ENGINE LUCENE")).execute();
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OLucenePerFieldAnalyzerWrapper(com.orientechnologies.lucene.analyzer.OLucenePerFieldAnalyzerWrapper) OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) IndexWriter(org.apache.lucene.index.IndexWriter) InputStream(java.io.InputStream) OCommandScript(com.orientechnologies.orient.core.command.script.OCommandScript) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) IOException(java.io.IOException) Directory(org.apache.lucene.store.Directory) NIOFSDirectory(org.apache.lucene.store.NIOFSDirectory) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) Before(org.junit.Before)

Aggregations

OLucenePerFieldAnalyzerWrapper (com.orientechnologies.lucene.analyzer.OLucenePerFieldAnalyzerWrapper)1 OCommandScript (com.orientechnologies.orient.core.command.script.OCommandScript)1 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)1 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)1 IndexWriter (org.apache.lucene.index.IndexWriter)1 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)1 Directory (org.apache.lucene.store.Directory)1 NIOFSDirectory (org.apache.lucene.store.NIOFSDirectory)1 Before (org.junit.Before)1