diff --git a/gplx.gflucene/src/gplx/gflucene/core/Gflucene_index_data.java b/gplx.gflucene/src/gplx/gflucene/core/Gflucene_index_data.java index 41e987dfd..925e2c8a4 100644 --- a/gplx.gflucene/src/gplx/gflucene/core/Gflucene_index_data.java +++ b/gplx.gflucene/src/gplx/gflucene/core/Gflucene_index_data.java @@ -18,6 +18,7 @@ import gplx.gflucene.analyzers.*; public class Gflucene_index_data { public final Gflucene_analyzer_data analyzer_data; public final String index_dir; + public final float max_merged_segments = 500; // "limits" maximum file size approximately; limiting to 500 MB should limit file size to around 1 GB public Gflucene_index_data(Gflucene_analyzer_data analyzer_data, String index_dir) { this.analyzer_data = analyzer_data; this.index_dir = index_dir; diff --git a/gplx.gflucene/src/gplx/gflucene/indexers/Gflucene_indexer_mgr.java b/gplx.gflucene/src/gplx/gflucene/indexers/Gflucene_indexer_mgr.java index 79530626f..8e6898e4d 100644 --- a/gplx.gflucene/src/gplx/gflucene/indexers/Gflucene_indexer_mgr.java +++ b/gplx.gflucene/src/gplx/gflucene/indexers/Gflucene_indexer_mgr.java @@ -25,6 +25,7 @@ import org.apache.lucene.document.*; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; +import org.apache.lucene.index.TieredMergePolicy; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; @@ -44,6 +45,11 @@ public class Gflucene_indexer_mgr { this.analyzer = Gflucene_analyzer_mgr_.New_analyzer(idx_data.analyzer_data.key); this.config = new IndexWriterConfig(analyzer); + // limit max size by setting merge policy + TieredMergePolicy merge_policy = new TieredMergePolicy(); + merge_policy.setMaxMergedSegmentMB(idx_data.max_merged_segments); + config.setMergePolicy(merge_policy); + // create index Path path = Paths.get(idx_data.index_dir); try { @@ -55,6 +61,7 @@ public class Gflucene_indexer_mgr { // create writer try { wtr = new IndexWriter(index, config); +// ((TieredMergePolicy)config.getMergePolicy()). } catch (IOException e) { throw Err_.new_exc(e, "lucene_index", "failed to create writer"); }