本文整理汇总了Java中org.apache.lucene.codecs.lucene41.Lucene41RWCodec类的典型用法代码示例。如果您正苦于以下问题:Java Lucene41RWCodec类的具体用法?Java Lucene41RWCodec怎么用?Java Lucene41RWCodec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Lucene41RWCodec类属于org.apache.lucene.codecs.lucene41包,在下文中一共展示了Lucene41RWCodec类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDisableImpersonation
import org.apache.lucene.codecs.lucene41.Lucene41RWCodec; //导入依赖的package包/类
public void testDisableImpersonation() throws Exception {
Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec() };
Directory dir = newDirectory();
IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
conf.setCodec(oldCodecs[random().nextInt(oldCodecs.length)]);
IndexWriter writer = new IndexWriter(dir, conf);
Document doc = new Document();
doc.add(new StringField("f", "bar", Store.YES));
doc.add(new NumericDocValuesField("n", 18L));
writer.addDocument(doc);
OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
try {
writer.close();
fail("should not have succeeded to impersonate an old format!");
} catch (UnsupportedOperationException e) {
writer.rollback();
} finally {
OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
}
dir.close();
}
示例2: testDisableImpersonation
import org.apache.lucene.codecs.lucene41.Lucene41RWCodec; //导入依赖的package包/类
public void testDisableImpersonation() throws Exception {
Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec() };
Directory dir = newDirectory();
IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
conf.setCodec(oldCodecs[random().nextInt(oldCodecs.length)]);
IndexWriter writer = new IndexWriter(dir, conf);
Document doc = new Document();
doc.add(new StringField("f", "bar", Store.YES));
doc.add(new NumericDocValuesField("n", 18L));
writer.addDocument(doc);
OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
try {
writer.close();
fail("should not have succeeded to impersonate an old format!");
} catch (UnsupportedOperationException e) {
writer.rollback();
} finally {
OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
}
dir.close();
}
示例3: testUpdateOldSegments
import org.apache.lucene.codecs.lucene41.Lucene41RWCodec; //导入依赖的package包/类
public void testUpdateOldSegments() throws Exception {
Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec(), new Lucene45RWCodec() };
Directory dir = newDirectory();
boolean oldValue = OLD_FORMAT_IMPERSONATION_IS_ACTIVE;
// create a segment with an old Codec
IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
conf.setCodec(oldCodecs[random().nextInt(oldCodecs.length)]);
OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
IndexWriter writer = new IndexWriter(dir, conf);
Document doc = new Document();
doc.add(new StringField("id", "doc", Store.NO));
doc.add(new BinaryDocValuesField("f", toBytes(5L)));
writer.addDocument(doc);
writer.close();
conf = newIndexWriterConfig(new MockAnalyzer(random()));
writer = new IndexWriter(dir, conf);
writer.updateBinaryDocValue(new Term("id", "doc"), "f", toBytes(4L));
OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
try {
writer.close();
fail("should not have succeeded to update a segment written with an old Codec");
} catch (UnsupportedOperationException e) {
writer.rollback();
} finally {
OLD_FORMAT_IMPERSONATION_IS_ACTIVE = oldValue;
}
dir.close();
}
示例4: testUpdateOldSegments
import org.apache.lucene.codecs.lucene41.Lucene41RWCodec; //导入依赖的package包/类
@Test
public void testUpdateOldSegments() throws Exception {
Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec(), new Lucene45RWCodec() };
Directory dir = newDirectory();
boolean oldValue = OLD_FORMAT_IMPERSONATION_IS_ACTIVE;
// create a segment with an old Codec
IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
conf.setCodec(oldCodecs[random().nextInt(oldCodecs.length)]);
OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
IndexWriter writer = new IndexWriter(dir, conf);
Document doc = new Document();
doc.add(new StringField("id", "doc", Store.NO));
doc.add(new NumericDocValuesField("f", 5));
writer.addDocument(doc);
writer.close();
conf = newIndexWriterConfig(new MockAnalyzer(random()));
writer = new IndexWriter(dir, conf);
writer.updateNumericDocValue(new Term("id", "doc"), "f", 4L);
OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
try {
writer.close();
fail("should not have succeeded to update a segment written with an old Codec");
} catch (UnsupportedOperationException e) {
writer.rollback();
} finally {
OLD_FORMAT_IMPERSONATION_IS_ACTIVE = oldValue;
}
dir.close();
}
示例5: testUpdateOldSegments
import org.apache.lucene.codecs.lucene41.Lucene41RWCodec; //导入依赖的package包/类
@Test
public void testUpdateOldSegments() throws Exception {
Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec(), new Lucene45RWCodec() };
Directory dir = newDirectory();
// create a segment with an old Codec
IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
conf.setCodec(oldCodecs[random().nextInt(oldCodecs.length)]);
IndexWriter writer = new IndexWriter(dir, conf);
Document doc = new Document();
doc.add(new StringField("id", "doc", Store.NO));
doc.add(new NumericDocValuesField("f", 5));
writer.addDocument(doc);
writer.close();
conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
writer = new IndexWriter(dir, conf);
writer.updateNumericDocValue(new Term("id", "doc"), "f", 4L);
OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
try {
writer.close();
fail("should not have succeeded to update a segment written with an old Codec");
} catch (UnsupportedOperationException e) {
writer.rollback();
} finally {
OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
}
dir.close();
}