func indexDocuments(engine factory.SearchEngine) (int64, int) { // prepare documents for batch index files, err := ioutil.ReadDir(*pathToFolder) utils.ErrorCheck(err) var docCount int = 0 var documents = make([]*factory.Document, len(files)) for _, file := range files { if file.IsDir() { continue // expected flat structure } path := *pathToFolder + "/" + file.Name() data, err := utils.ReadFile(path) utils.ErrorCheck(err) documents[docCount] = &factory.Document{utils.FixIdSyntax(path), data} docCount++ } // index in batch timeTook, err := engine.BatchIndex(documents) utils.ErrorCheck(err) return timeTook, docCount }