mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Full-text search: Limit index size to default of 1 GB
This commit is contained in:
parent
a214575391
commit
66eeef6ab1
@ -18,6 +18,7 @@ import gplx.gflucene.analyzers.*;
|
|||||||
public class Gflucene_index_data {
|
public class Gflucene_index_data {
|
||||||
public final Gflucene_analyzer_data analyzer_data;
|
public final Gflucene_analyzer_data analyzer_data;
|
||||||
public final String index_dir;
|
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) {
|
public Gflucene_index_data(Gflucene_analyzer_data analyzer_data, String index_dir) {
|
||||||
this.analyzer_data = analyzer_data;
|
this.analyzer_data = analyzer_data;
|
||||||
this.index_dir = index_dir;
|
this.index_dir = index_dir;
|
||||||
|
@ -25,6 +25,7 @@ import org.apache.lucene.document.*;
|
|||||||
import org.apache.lucene.index.IndexOptions;
|
import org.apache.lucene.index.IndexOptions;
|
||||||
import org.apache.lucene.index.IndexWriter;
|
import org.apache.lucene.index.IndexWriter;
|
||||||
import org.apache.lucene.index.IndexWriterConfig;
|
import org.apache.lucene.index.IndexWriterConfig;
|
||||||
|
import org.apache.lucene.index.TieredMergePolicy;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.FSDirectory;
|
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.analyzer = Gflucene_analyzer_mgr_.New_analyzer(idx_data.analyzer_data.key);
|
||||||
this.config = new IndexWriterConfig(analyzer);
|
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
|
// create index
|
||||||
Path path = Paths.get(idx_data.index_dir);
|
Path path = Paths.get(idx_data.index_dir);
|
||||||
try {
|
try {
|
||||||
@ -55,6 +61,7 @@ public class Gflucene_indexer_mgr {
|
|||||||
// create writer
|
// create writer
|
||||||
try {
|
try {
|
||||||
wtr = new IndexWriter(index, config);
|
wtr = new IndexWriter(index, config);
|
||||||
|
// ((TieredMergePolicy)config.getMergePolicy()).
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw Err_.new_exc(e, "lucene_index", "failed to create writer");
|
throw Err_.new_exc(e, "lucene_index", "failed to create writer");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user