From a8de6aee424ede4d2a1aeba7f605d46c48e7aff7 Mon Sep 17 00:00:00 2001 From: gotoeasy Date: Tue, 23 Jul 2024 11:17:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=89=E9=A1=B9=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=90=8C=E6=AD=A5=E5=88=9B=E5=BB=BA=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- glc/conf/config.go | 7 +++++++ glc/ldb/storage/logdata/logdata_storage.go | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/glc/conf/config.go b/glc/conf/config.go index f560d51..ffa9f8e 100644 --- a/glc/conf/config.go +++ b/glc/conf/config.go @@ -61,6 +61,7 @@ var aryWhite []string var aryBlack []string var ipAddCity bool var enableChatAi bool +var createIndexSync bool func init() { UpdateConfigByEnv() @@ -106,6 +107,12 @@ func UpdateConfigByEnv() { mulitLineSearch = cmn.GetEnvBool("GLC_SEARCH_MULIT_LINE", false) // 是否检索日志的全部行(日志可能有换行),默认false仅第一行 testMode = cmn.GetEnvBool("GLC_TEST_MODE", false) // 是否测试模式,默认false enableChatAi = cmn.GetEnvBool("GLC_ENABLE_CHATAI", true) // 是否开启GLC智能助手,默认true + createIndexSync = cmn.GetEnvBool("GLC_CREATE_INDEX_SYNC", false) // 是否同步创建索引,默认false +} + +// 取配置: 是否同步创建索引 +func IsCreateIndexSync() bool { + return createIndexSync } // 取配置: 是否开启GLC智能助手 diff --git a/glc/ldb/storage/logdata/logdata_storage.go b/glc/ldb/storage/logdata/logdata_storage.go index 25a6ceb..513710e 100644 --- a/glc/ldb/storage/logdata/logdata_storage.go +++ b/glc/ldb/storage/logdata/logdata_storage.go @@ -133,6 +133,10 @@ func (s *LogDataStorage) readyGo() { break } s.saveLogData(data) // 保存日志数据 + + if conf.IsCreateIndexSync() { + s.createInvertedIndex() // 按配置要求同步生成反向索引 + } default: // 空时再生成索引,一次一条日志,有空则生成直到全部完成 n := s.createInvertedIndex() // 生成反向索引