diff --git a/lucene/misc/src/java/org/apache/lucene/misc/index/IndexWriterConfigs.java b/lucene/misc/src/java/org/apache/lucene/misc/index/IndexWriterConfigs.java new file mode 100644 index 00000000000..9b411db0799 --- /dev/null +++ b/lucene/misc/src/java/org/apache/lucene/misc/index/IndexWriterConfigs.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.lucene.misc.index; + +import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.index.IndexWriterConfig; +import org.apache.lucene.index.LogByteSizeMergePolicy; +import org.apache.lucene.index.SimpleMergedSegmentWarmer; +import org.apache.lucene.index.TieredMergePolicy; +import org.apache.lucene.util.InfoStream; + +/** Factory methods for {@link IndexWriterConfig}s with sensible defaults for various use-cases. */ +public class IndexWriterConfigs { + + // Prevent instantiation + private IndexWriterConfigs() {} + + /** + * Create a new {@link IndexWriterConfig} for time-based data. It internally configures a {@link + * LogByteSizeMergePolicy}, whose policy of only merging adjacent segments helps keep the time + * range overlap between segments very low. This in-turn makes filtering on timestamp ranges + * faster. + */ + public static IndexWriterConfig forTimeBasedData() { + IndexWriterConfig config = new IndexWriterConfig(); + config.setMergePolicy(new LogByteSizeMergePolicy()); + return config; + } + + /** + * Create a new {@link IndexWriterConfig} that optimized for fast near-realtime search. Internally + * it: + * + *