本文整理匯總了Java中org.apache.lucene.codecs.mocksep.MockSepPostingsFormat類的典型用法代碼示例。如果您正苦於以下問題:Java MockSepPostingsFormat類的具體用法?Java MockSepPostingsFormat怎麽用?Java MockSepPostingsFormat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MockSepPostingsFormat類屬於org.apache.lucene.codecs.mocksep包,在下文中一共展示了MockSepPostingsFormat類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: RandomCodec
import org.apache.lucene.codecs.mocksep.MockSepPostingsFormat; //導入依賴的package包/類
public RandomCodec(Random random, Set<String> avoidCodecs) {
this.perFieldSeed = random.nextInt();
this.avoidCodecs = avoidCodecs;
// TODO: make it possible to specify min/max iterms per
// block via CL:
int minItemsPerBlock = TestUtil.nextInt(random, 2, 100);
int maxItemsPerBlock = 2*(Math.max(2, minItemsPerBlock-1)) + random.nextInt(100);
int lowFreqCutoff = TestUtil.nextInt(random, 2, 100);
add(avoidCodecs,
new Lucene41PostingsFormat(minItemsPerBlock, maxItemsPerBlock),
new FSTPostingsFormat(),
new FSTOrdPostingsFormat(),
new FSTPulsing41PostingsFormat(1 + random.nextInt(20)),
new FSTOrdPulsing41PostingsFormat(1 + random.nextInt(20)),
new DirectPostingsFormat(LuceneTestCase.rarely(random) ? 1 : (LuceneTestCase.rarely(random) ? Integer.MAX_VALUE : maxItemsPerBlock),
LuceneTestCase.rarely(random) ? 1 : (LuceneTestCase.rarely(random) ? Integer.MAX_VALUE : lowFreqCutoff)),
new Pulsing41PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
// add pulsing again with (usually) different parameters
new Pulsing41PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
//TODO as a PostingsFormat which wraps others, we should allow TestBloomFilteredLucene41Postings to be constructed
//with a choice of concrete PostingsFormats. Maybe useful to have a generic means of marking and dealing
//with such "wrapper" classes?
new TestBloomFilteredLucene41Postings(),
new MockSepPostingsFormat(),
new MockFixedIntBlockPostingsFormat(TestUtil.nextInt(random, 1, 2000)),
new MockVariableIntBlockPostingsFormat( TestUtil.nextInt(random, 1, 127)),
new MockRandomPostingsFormat(random),
new NestedPulsingPostingsFormat(),
new Lucene41WithOrds(),
new SimpleTextPostingsFormat(),
new AssertingPostingsFormat(),
new MemoryPostingsFormat(true, random.nextFloat()),
new MemoryPostingsFormat(false, random.nextFloat()));
addDocValues(avoidCodecs,
new Lucene410DocValuesFormat(),
new MemoryDocValuesFormat(),
new SimpleTextDocValuesFormat(),
new AssertingDocValuesFormat());
Collections.shuffle(formats, random);
Collections.shuffle(dvFormats, random);
// Avoid too many open files:
if (formats.size() > 4) {
formats = formats.subList(0, 4);
}
if (dvFormats.size() > 4) {
dvFormats = dvFormats.subList(0, 4);
}
}
示例2: testSepPositionAfterMerge
import org.apache.lucene.codecs.mocksep.MockSepPostingsFormat; //導入依賴的package包/類
public void testSepPositionAfterMerge() throws IOException {
final Directory dir = newDirectory();
final IndexWriterConfig config = newIndexWriterConfig(new MockAnalyzer(random()));
config.setMergePolicy(newLogMergePolicy());
config.setCodec(TestUtil.alwaysPostingsFormat(new MockSepPostingsFormat()));
final IndexWriter writer = new IndexWriter(dir, config);
try {
final PhraseQuery pq = new PhraseQuery();
pq.add(new Term("content", "bbb"));
pq.add(new Term("content", "ccc"));
final Document doc = new Document();
FieldType customType = new FieldType(TextField.TYPE_NOT_STORED);
customType.setOmitNorms(true);
doc.add(newField("content", "aaa bbb ccc ddd", customType));
// add document and force commit for creating a first segment
writer.addDocument(doc);
writer.commit();
ScoreDoc[] results = this.search(writer, pq, 5);
assertEquals(1, results.length);
assertEquals(0, results[0].doc);
// add document and force commit for creating a second segment
writer.addDocument(doc);
writer.commit();
// at this point, there should be at least two segments
results = this.search(writer, pq, 5);
assertEquals(2, results.length);
assertEquals(0, results[0].doc);
writer.forceMerge(1);
// optimise to merge the segments.
results = this.search(writer, pq, 5);
assertEquals(2, results.length);
assertEquals(0, results[0].doc);
}
finally {
writer.close();
dir.close();
}
}
示例3: RandomCodec
import org.apache.lucene.codecs.mocksep.MockSepPostingsFormat; //導入依賴的package包/類
public RandomCodec(Random random, Set<String> avoidCodecs) {
this.perFieldSeed = random.nextInt();
// TODO: make it possible to specify min/max iterms per
// block via CL:
int minItemsPerBlock = _TestUtil.nextInt(random, 2, 100);
int maxItemsPerBlock = 2*(Math.max(2, minItemsPerBlock-1)) + random.nextInt(100);
int lowFreqCutoff = _TestUtil.nextInt(random, 2, 100);
add(avoidCodecs,
new Lucene41PostingsFormat(minItemsPerBlock, maxItemsPerBlock),
new DirectPostingsFormat(LuceneTestCase.rarely(random) ? 1 : (LuceneTestCase.rarely(random) ? Integer.MAX_VALUE : maxItemsPerBlock),
LuceneTestCase.rarely(random) ? 1 : (LuceneTestCase.rarely(random) ? Integer.MAX_VALUE : lowFreqCutoff)),
new Pulsing41PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
// add pulsing again with (usually) different parameters
new Pulsing41PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
//TODO as a PostingsFormat which wraps others, we should allow TestBloomFilteredLucene41Postings to be constructed
//with a choice of concrete PostingsFormats. Maybe useful to have a generic means of marking and dealing
//with such "wrapper" classes?
new TestBloomFilteredLucene41Postings(),
new MockSepPostingsFormat(),
new MockFixedIntBlockPostingsFormat(_TestUtil.nextInt(random, 1, 2000)),
new MockVariableIntBlockPostingsFormat( _TestUtil.nextInt(random, 1, 127)),
new MockRandomPostingsFormat(random),
new NestedPulsingPostingsFormat(),
new Lucene41WithOrds(),
new SimpleTextPostingsFormat(),
new AssertingPostingsFormat(),
new MemoryPostingsFormat(true, random.nextFloat()),
new MemoryPostingsFormat(false, random.nextFloat()));
addDocValues(avoidCodecs,
new Lucene42DocValuesFormat(),
new DiskDocValuesFormat(),
new SimpleTextDocValuesFormat(),
new AssertingDocValuesFormat(),
new CheapBastardDocValuesFormat());
Collections.shuffle(formats, random);
Collections.shuffle(dvFormats, random);
// Avoid too many open files:
if (formats.size() > 4) {
formats = formats.subList(0, 4);
}
if (dvFormats.size() > 4) {
dvFormats = dvFormats.subList(0, 4);
}
}
示例4: testSepPositionAfterMerge
import org.apache.lucene.codecs.mocksep.MockSepPostingsFormat; //導入依賴的package包/類
public void testSepPositionAfterMerge() throws IOException {
final Directory dir = newDirectory();
final IndexWriterConfig config = newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(random()));
config.setMergePolicy(newLogMergePolicy());
config.setCodec(_TestUtil.alwaysPostingsFormat(new MockSepPostingsFormat()));
final IndexWriter writer = new IndexWriter(dir, config);
try {
final PhraseQuery pq = new PhraseQuery();
pq.add(new Term("content", "bbb"));
pq.add(new Term("content", "ccc"));
final Document doc = new Document();
FieldType customType = new FieldType(TextField.TYPE_NOT_STORED);
customType.setOmitNorms(true);
doc.add(newField("content", "aaa bbb ccc ddd", customType));
// add document and force commit for creating a first segment
writer.addDocument(doc);
writer.commit();
ScoreDoc[] results = this.search(writer, pq, 5);
assertEquals(1, results.length);
assertEquals(0, results[0].doc);
// add document and force commit for creating a second segment
writer.addDocument(doc);
writer.commit();
// at this point, there should be at least two segments
results = this.search(writer, pq, 5);
assertEquals(2, results.length);
assertEquals(0, results[0].doc);
writer.forceMerge(1);
// optimise to merge the segments.
results = this.search(writer, pq, 5);
assertEquals(2, results.length);
assertEquals(0, results[0].doc);
}
finally {
writer.close();
dir.close();
}
}
示例5: RandomCodec
import org.apache.lucene.codecs.mocksep.MockSepPostingsFormat; //導入依賴的package包/類
public RandomCodec(Random random, Set<String> avoidCodecs) {
this.perFieldSeed = random.nextInt();
// TODO: make it possible to specify min/max iterms per
// block via CL:
int minItemsPerBlock = _TestUtil.nextInt(random, 2, 100);
int maxItemsPerBlock = 2*(Math.max(2, minItemsPerBlock-1)) + random.nextInt(100);
int lowFreqCutoff = _TestUtil.nextInt(random, 2, 100);
add(avoidCodecs,
new Lucene41PostingsFormat(minItemsPerBlock, maxItemsPerBlock),
new DirectPostingsFormat(LuceneTestCase.rarely(random) ? 1 : (LuceneTestCase.rarely(random) ? Integer.MAX_VALUE : maxItemsPerBlock),
LuceneTestCase.rarely(random) ? 1 : (LuceneTestCase.rarely(random) ? Integer.MAX_VALUE : lowFreqCutoff)),
new Pulsing41PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
// add pulsing again with (usually) different parameters
new Pulsing41PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
//TODO as a PostingsFormat which wraps others, we should allow TestBloomFilteredLucene41Postings to be constructed
//with a choice of concrete PostingsFormats. Maybe useful to have a generic means of marking and dealing
//with such "wrapper" classes?
new TestBloomFilteredLucene41Postings(),
new MockSepPostingsFormat(),
new MockFixedIntBlockPostingsFormat(_TestUtil.nextInt(random, 1, 2000)),
new MockVariableIntBlockPostingsFormat( _TestUtil.nextInt(random, 1, 127)),
new MockRandomPostingsFormat(random),
new NestedPulsingPostingsFormat(),
new Lucene41WithOrds(),
new SimpleTextPostingsFormat(),
new AssertingPostingsFormat(),
new MemoryPostingsFormat(true, random.nextFloat()),
new MemoryPostingsFormat(false, random.nextFloat()));
addDocValues(avoidCodecs,
new Lucene45DocValuesFormat(),
new DiskDocValuesFormat(),
new MemoryDocValuesFormat(),
new SimpleTextDocValuesFormat(),
new AssertingDocValuesFormat());
Collections.shuffle(formats, random);
Collections.shuffle(dvFormats, random);
// Avoid too many open files:
if (formats.size() > 4) {
formats = formats.subList(0, 4);
}
if (dvFormats.size() > 4) {
dvFormats = dvFormats.subList(0, 4);
}
}