This commit is contained in:
2026-04-10 00:37:08 +08:00
parent fa5e451dde
commit dddc445955
2 changed files with 92 additions and 13 deletions
+10
View File
@@ -59,6 +59,7 @@ type SearchConfig struct {
BacklinkWeight float64 `yaml:"backlink_weight"`
ServerPort int `yaml:"server_port"`
FlushIntervalSeconds int `yaml:"flush_interval_seconds"`
StatsRefreshInterval int `yaml:"stats_refresh_interval"` // 统计缓存刷新间隔(秒),默认 30
MissPenalty float64 `yaml:"miss_penalty"` // 缺词惩罚系数(0=不惩罚,1=完全忽略缺词URL),默认 0.15
}
@@ -137,6 +138,7 @@ func GetDefaultConfig() Config {
BacklinkWeight: 1.0,
ServerPort: 50082,
FlushIntervalSeconds: 300,
StatsRefreshInterval: 30,
MissPenalty: 0.15,
},
Backlink: BacklinkConfig{
@@ -249,6 +251,14 @@ func SearchServerPort() int { return Global.Search.ServerPort }
// FlushIntervalSeconds 返回配置值
func FlushIntervalSeconds() int { return Global.Search.FlushIntervalSeconds }
// StatsRefreshInterval 返回统计缓存刷新间隔(秒),默认 30。
func StatsRefreshInterval() int {
if Global.Search.StatsRefreshInterval <= 0 {
return 30
}
return Global.Search.StatsRefreshInterval
}
// MissPenalty 返回缺词惩罚系数(0~1),值越大对缺少查询词的 URL 惩罚越重。
func MissPenalty() float64 { return Global.Search.MissPenalty }