|
|
@@ -28,6 +28,12 @@ var (
|
|
|
)
|
|
|
|
|
|
type EngineInitOptions struct {
|
|
|
+ // 是否使用分词器
|
|
|
+ // 默认使用,否则在启动阶段跳过SegmenterDictionaries和StopTokenFile设置
|
|
|
+ // 如果你不需要在引擎内分词,可以将这个选项设为true
|
|
|
+ // 注意,如果你不用分词器,那么在调用IndexDocument时DocumentIndexData中的Content会被忽略
|
|
|
+ NotUsingSegmenter bool
|
|
|
+
|
|
|
// 半角逗号分隔的字典文件,具体用法见
|
|
|
// sego.Segmenter.LoadDictionary函数的注释
|
|
|
SegmenterDictionaries string
|
|
|
@@ -61,15 +67,17 @@ type EngineInitOptions struct {
|
|
|
DefaultRankOptions *RankOptions
|
|
|
|
|
|
// 是否使用持久数据库,以及数据库文件保存的目录和裂分数目
|
|
|
- UsePersistentStorage bool
|
|
|
+ UsePersistentStorage bool
|
|
|
PersistentStorageFolder string
|
|
|
PersistentStorageShards int
|
|
|
}
|
|
|
|
|
|
// 初始化EngineInitOptions,当用户未设定某个选项的值时用默认值取代
|
|
|
func (options *EngineInitOptions) Init() {
|
|
|
- if options.SegmenterDictionaries == "" {
|
|
|
- log.Fatal("字典文件不能为空")
|
|
|
+ if !options.NotUsingSegmenter {
|
|
|
+ if options.SegmenterDictionaries == "" {
|
|
|
+ log.Fatal("字典文件不能为空")
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if options.NumSegmenterThreads == 0 {
|