Mercurial Hosting > luan
diff src/luan/modules/lucene/LuceneIndex.java @ 1672:8dd8c556c449
backup work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 26 May 2022 21:10:02 -0600 |
parents | 582384548a69 |
children | 1b9f9fdb3b41 |
line wrap: on
line diff
--- a/src/luan/modules/lucene/LuceneIndex.java Thu May 12 10:56:45 2022 -0600 +++ b/src/luan/modules/lucene/LuceneIndex.java Thu May 26 21:10:02 2022 -0600 @@ -81,6 +81,7 @@ import goodjava.lucene.api.LuceneUtils; import goodjava.lucene.logging.LoggingIndexWriter; import goodjava.lucene.logging.OpDoer; +import goodjava.lucene.backup.BackupIndexWriter; import goodjava.parser.ParseException; import luan.modules.Utils; import luan.Luan; @@ -146,6 +147,9 @@ private boolean wasCreated; private final File logDir; private final long logTime; + private final String name; + private final String domain; + private final String password; private LuceneIndex(Luan luan,File indexDir,LuanTable options) throws LuanException, IOException, ClassNotFoundException, SQLException @@ -159,8 +163,24 @@ LuanFunction supplementer = Utils.removeFunction(options,"supplementer"); logDir = (File)options.remove("log_dir"); logTime = (Long)options.remove("log_time"); + name = (String)options.remove("name"); Utils.checkEmpty(options); + { + LuanTable module = (LuanTable)luan.require("luan:http/Http.luan"); + String domain = (String)module.get(luan,"domain"); + if( domain == null ) + domain = "localhost"; + this.domain = domain; + } + { + LuanTable module = (LuanTable)luan.require("luan:Io.luan"); + String password = (String)module.get(luan,"password"); + if( password == null ) + password = "password"; + this.password = password; + } + mfp = defaultFieldParser==null ? new MultiFieldParser() : new MultiFieldParser(defaultFieldParser,defaultFields); mfp.fields.put( "type", STRING_FIELD_PARSER ); mfp.fields.put( "id", NumberFieldParser.LONG ); @@ -193,8 +213,17 @@ fsDir = FSDirectory.open(indexDir); boolean wasCreated = !fsDir.getDirectory().exists(); writer = new LuceneIndexWriter(fsDir,config); - if( logDir != null ) - writer = new LoggingIndexWriter((LuceneIndexWriter)writer,logDir,logTime); + if( logDir != null ) { + if( BackupIndexWriter.backupDomains == null ) { + writer = new LoggingIndexWriter((LuceneIndexWriter)writer,logDir,logTime); + } else { + String name = this.domain; + if( this.name != null ) + name += "~" + this.name; + writer = new BackupIndexWriter((LuceneIndexWriter)writer,logDir,logTime,name,password); +//qqq + } + } reader = DirectoryReader.open(fsDir); searcher = new IndexSearcher(reader); initId();