package i2es import ( log "github.com/Sirupsen/logrus" "github.com/google/uuid" ) // AssignTopics ... func (es ESConf) AssignTopics(messages []ESDoc) error { for _, message := range messages { // generate new topicid if message.Repto == "" && message.TopicID == "" { message.TopicID = uuid.New().String() err := es.PutToIndex(message) if err != nil { log.Error(err.Error()) continue } } // skip message with assigned topicid if message.TopicID != "" { continue } // find top message of the thread and get they topicid if message.Repto != "" { t := topicid{es} topicid, err := t.findTopicID(message.MsgID, 0) if err != nil { message.Misplaced = "yes" err := es.PutToIndex(message) if err != nil { log.Error(err.Error()) continue } continue } message.TopicID = topicid err = es.PutToIndex(message) if err != nil { log.Error(err.Error()) continue } } } return nil }