go-ego / riot

Go Open Source, Distributed, Simple and efficient Search Engine; Warning: This is V1 and beta version, because of big memory consume, and the V2 will be rewrite all code.
Apache License 2.0
6.11k stars 473 forks source link

What is the function of the DocData field Attri? How to store Attri? #66

Open yale8848 opened 5 years ago

yale8848 commented 5 years ago
type DocData struct {
    ...
    Attri interface{}
    ...
}
  1. What is the function of the Attri ?
  2. I test to store the Attri , but it was fail. Flow is the code:
type parentInfo struct{
    Name string
    Id int64
}
type resIndexNode struct {
    Id int64
    Name string
    Attr []parentInfo
}
...
searcher.Init(types.EngineOpts{
        Using: 3,
        UseStore: true,
        StoreFolder:dataPath,
})
...

func addIndex(rin*resIndexNode)  {
    searcher.Index(uint64(rin.Id), types.DocData{Content: rin.Name,Attri:rin.Attr},true)
    searcher.Flush()
}

reload index:

func reloadIndex(dataPath string)  {

    searcher.Init(types.EngineOpts{
        Using: 3,
        UseStore: true,
        StoreFolder:dataPath,
    })
    searcher.FlushIndex()

    log.Println("recover index number: ", searcher.NumDocsIndexed())
}

searcher.NumDocsIndexed() is 0

vcaesar commented 5 years ago

I reproduced your question, I will update it.