Search in sources :

Example 1 with LogDocMergePolicy

use of org.apache.lucene.index.LogDocMergePolicy in project lucene-solr by apache.

the class TestBlockJoin method testAdvanceSingleParentNoChild.

public void testAdvanceSingleParentNoChild() throws Exception {
    Directory dir = newDirectory();
    RandomIndexWriter w = new RandomIndexWriter(random(), dir, newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(new LogDocMergePolicy()));
    Document parentDoc = new Document();
    parentDoc.add(newStringField("parent", "1", Field.Store.NO));
    parentDoc.add(newStringField("isparent", "yes", Field.Store.NO));
    w.addDocuments(Arrays.asList(parentDoc));
    // Add another doc so scorer is not null
    parentDoc = new Document();
    parentDoc.add(newStringField("parent", "2", Field.Store.NO));
    parentDoc.add(newStringField("isparent", "yes", Field.Store.NO));
    Document childDoc = new Document();
    childDoc.add(newStringField("child", "2", Field.Store.NO));
    w.addDocuments(Arrays.asList(childDoc, parentDoc));
    // Need single seg:
    w.forceMerge(1);
    IndexReader r = w.getReader();
    w.close();
    IndexSearcher s = newSearcher(r);
    Query tq = new TermQuery(new Term("child", "2"));
    BitSetProducer parentFilter = new QueryBitSetProducer(new TermQuery(new Term("isparent", "yes")));
    CheckJoinIndex.check(s.getIndexReader(), parentFilter);
    ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(tq, parentFilter, ScoreMode.Avg);
    Weight weight = s.createNormalizedWeight(q, true);
    Scorer sc = weight.scorer(s.getIndexReader().leaves().get(0));
    assertEquals(2, sc.iterator().advance(0));
    r.close();
    dir.close();
}
Also used : LogDocMergePolicy(org.apache.lucene.index.LogDocMergePolicy) Term(org.apache.lucene.index.Term) Document(org.apache.lucene.document.Document) MockAnalyzer(org.apache.lucene.analysis.MockAnalyzer) IndexReader(org.apache.lucene.index.IndexReader) RandomIndexWriter(org.apache.lucene.index.RandomIndexWriter) Directory(org.apache.lucene.store.Directory)

Example 2 with LogDocMergePolicy

use of org.apache.lucene.index.LogDocMergePolicy in project lucene-solr by apache.

the class TestFieldCache method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    NUM_DOCS = atLeast(500);
    NUM_ORDS = atLeast(2);
    directory = newDirectory();
    IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(new LogDocMergePolicy()));
    long theLong = Long.MAX_VALUE;
    double theDouble = Double.MAX_VALUE;
    int theInt = Integer.MAX_VALUE;
    float theFloat = Float.MAX_VALUE;
    unicodeStrings = new String[NUM_DOCS];
    multiValued = new BytesRef[NUM_DOCS][NUM_ORDS];
    if (VERBOSE) {
        System.out.println("TEST: setUp");
    }
    for (int i = 0; i < NUM_DOCS; i++) {
        Document doc = new Document();
        doc.add(new LongPoint("theLong", theLong--));
        doc.add(new DoublePoint("theDouble", theDouble--));
        doc.add(new IntPoint("theInt", theInt--));
        doc.add(new FloatPoint("theFloat", theFloat--));
        if (i % 2 == 0) {
            doc.add(new IntPoint("sparse", i));
        }
        if (i % 2 == 0) {
            doc.add(new IntPoint("numInt", i));
        }
        // sometimes skip the field:
        if (random().nextInt(40) != 17) {
            unicodeStrings[i] = generateString(i);
            doc.add(newStringField("theRandomUnicodeString", unicodeStrings[i], Field.Store.YES));
        }
        // sometimes skip the field:
        if (random().nextInt(10) != 8) {
            for (int j = 0; j < NUM_ORDS; j++) {
                String newValue = generateString(i);
                multiValued[i][j] = new BytesRef(newValue);
                doc.add(newStringField("theRandomUnicodeMultiValuedField", newValue, Field.Store.YES));
            }
            Arrays.sort(multiValued[i]);
        }
        writer.addDocument(doc);
    }
    // this test relies on one segment and docid order
    writer.forceMerge(1);
    IndexReader r = DirectoryReader.open(writer);
    assertEquals(1, r.leaves().size());
    reader = r.leaves().get(0).reader();
    TestUtil.checkReader(reader);
    writer.close();
}
Also used : LogDocMergePolicy(org.apache.lucene.index.LogDocMergePolicy) LongPoint(org.apache.lucene.document.LongPoint) Document(org.apache.lucene.document.Document) LongPoint(org.apache.lucene.document.LongPoint) DoublePoint(org.apache.lucene.document.DoublePoint) IntPoint(org.apache.lucene.document.IntPoint) FloatPoint(org.apache.lucene.document.FloatPoint) IntPoint(org.apache.lucene.document.IntPoint) MockAnalyzer(org.apache.lucene.analysis.MockAnalyzer) FloatPoint(org.apache.lucene.document.FloatPoint) IndexWriter(org.apache.lucene.index.IndexWriter) RandomIndexWriter(org.apache.lucene.index.RandomIndexWriter) DoublePoint(org.apache.lucene.document.DoublePoint) IndexReader(org.apache.lucene.index.IndexReader) BytesRef(org.apache.lucene.util.BytesRef) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) BeforeClass(org.junit.BeforeClass)

Example 3 with LogDocMergePolicy

use of org.apache.lucene.index.LogDocMergePolicy in project jackrabbit-oak by apache.

the class IndexDefinition method createMergePolicy.

private MergePolicy createMergePolicy() {
    String mmp = System.getProperty("oak.lucene.cmmp");
    if (mmp != null) {
        return new CommitMitigatingTieredMergePolicy();
    }
    String mergePolicyName = getOptionalValue(definition, LuceneIndexConstants.MERGE_POLICY_NAME, null);
    MergePolicy mergePolicy = null;
    if (mergePolicyName != null) {
        if (mergePolicyName.equalsIgnoreCase("no")) {
            mergePolicy = NoMergePolicy.COMPOUND_FILES;
        } else if (mergePolicyName.equalsIgnoreCase("mitigated")) {
            mergePolicy = new CommitMitigatingTieredMergePolicy();
        } else if (mergePolicyName.equalsIgnoreCase("tiered") || mergePolicyName.equalsIgnoreCase("default")) {
            mergePolicy = new TieredMergePolicy();
        } else if (mergePolicyName.equalsIgnoreCase("logbyte")) {
            mergePolicy = new LogByteSizeMergePolicy();
        } else if (mergePolicyName.equalsIgnoreCase("logdoc")) {
            mergePolicy = new LogDocMergePolicy();
        }
    }
    if (mergePolicy == null) {
        mergePolicy = new TieredMergePolicy();
    }
    return mergePolicy;
}
Also used : TieredMergePolicy(org.apache.lucene.index.TieredMergePolicy) CommitMitigatingTieredMergePolicy(org.apache.jackrabbit.oak.plugins.index.lucene.writer.CommitMitigatingTieredMergePolicy) CommitMitigatingTieredMergePolicy(org.apache.jackrabbit.oak.plugins.index.lucene.writer.CommitMitigatingTieredMergePolicy) LogByteSizeMergePolicy(org.apache.lucene.index.LogByteSizeMergePolicy) NoMergePolicy(org.apache.lucene.index.NoMergePolicy) MergePolicy(org.apache.lucene.index.MergePolicy) LogByteSizeMergePolicy(org.apache.lucene.index.LogByteSizeMergePolicy) LogDocMergePolicy(org.apache.lucene.index.LogDocMergePolicy) TieredMergePolicy(org.apache.lucene.index.TieredMergePolicy) CommitMitigatingTieredMergePolicy(org.apache.jackrabbit.oak.plugins.index.lucene.writer.CommitMitigatingTieredMergePolicy) LogDocMergePolicy(org.apache.lucene.index.LogDocMergePolicy)

Example 4 with LogDocMergePolicy

use of org.apache.lucene.index.LogDocMergePolicy in project OpenOLAT by OpenOLAT.

the class OlatFullIndexer method newLogMergePolicy.

public LogMergePolicy newLogMergePolicy() {
    LogMergePolicy logmp = new LogDocMergePolicy();
    logmp.setCalibrateSizeByDeletes(true);
    logmp.setMergeFactor(INDEX_MERGE_FACTOR);
    return logmp;
}
Also used : LogMergePolicy(org.apache.lucene.index.LogMergePolicy) LogDocMergePolicy(org.apache.lucene.index.LogDocMergePolicy)

Example 5 with LogDocMergePolicy

use of org.apache.lucene.index.LogDocMergePolicy in project OpenOLAT by OpenOLAT.

the class JmsIndexer method newLogMergePolicy.

public LogMergePolicy newLogMergePolicy() {
    LogMergePolicy logmp = new LogDocMergePolicy();
    logmp.setCalibrateSizeByDeletes(true);
    logmp.setMergeFactor(INDEX_MERGE_FACTOR);
    return logmp;
}
Also used : LogMergePolicy(org.apache.lucene.index.LogMergePolicy) LogDocMergePolicy(org.apache.lucene.index.LogDocMergePolicy)

Aggregations

LogDocMergePolicy (org.apache.lucene.index.LogDocMergePolicy)12 LongPoint (org.apache.lucene.document.LongPoint)4 LogMergePolicy (org.apache.lucene.index.LogMergePolicy)4 IndexReader (org.apache.lucene.index.IndexReader)3 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)3 MockAnalyzer (org.apache.lucene.analysis.MockAnalyzer)2 Document (org.apache.lucene.document.Document)2 IndexWriter (org.apache.lucene.index.IndexWriter)2 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)2 LogByteSizeMergePolicy (org.apache.lucene.index.LogByteSizeMergePolicy)2 ParsedDocument (org.elasticsearch.index.mapper.ParsedDocument)2 Store (org.elasticsearch.index.store.Store)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Test (org.junit.Test)2 CommitMitigatingTieredMergePolicy (org.apache.jackrabbit.oak.plugins.index.lucene.writer.CommitMitigatingTieredMergePolicy)1 DoublePoint (org.apache.lucene.document.DoublePoint)1 FloatPoint (org.apache.lucene.document.FloatPoint)1 IntPoint (org.apache.lucene.document.IntPoint)1 LeafReader (org.apache.lucene.index.LeafReader)1 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1