2018-11-11 11:59:58 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
|
|
|
|
"gitea.difrex.ru/Umbrella/fetcher/i2es"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
es, index, esType string
|
2018-11-12 15:39:24 +03:00
|
|
|
step, from, limit int
|
|
|
|
latest bool
|
2018-11-11 11:59:58 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
flag.StringVar(&es, "es", "http://127.0.0.1:9200", "Elasticsearch URL")
|
|
|
|
flag.StringVar(&index, "index", "idec", "Elasticsearch index")
|
|
|
|
flag.StringVar(&esType, "esType", "post", "Elasticsearch document type")
|
|
|
|
flag.IntVar(&step, "step", 100, "Scroll step")
|
2018-11-12 14:07:34 +03:00
|
|
|
flag.IntVar(&from, "from", 0, "Scroll from")
|
2018-11-12 15:39:24 +03:00
|
|
|
flag.IntVar(&limit, "limit", 2500, "Limit for latest posts")
|
|
|
|
flag.BoolVar(&latest, "latest", false, "Processing only latest posts")
|
2018-11-11 11:59:58 +03:00
|
|
|
flag.Parse()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
conf := Conf{
|
|
|
|
ES: i2es.ESConf{
|
|
|
|
Host: es,
|
|
|
|
Index: index,
|
|
|
|
Type: esType,
|
|
|
|
},
|
2018-11-12 15:39:24 +03:00
|
|
|
Step: step,
|
|
|
|
From: from,
|
|
|
|
Limit: limit,
|
2018-11-11 11:59:58 +03:00
|
|
|
}
|
2018-11-11 20:54:49 +03:00
|
|
|
con := newContainer()
|
2018-11-12 15:39:24 +03:00
|
|
|
if latest {
|
|
|
|
conf.assignLatests(&con)
|
|
|
|
} else {
|
|
|
|
conf.reassignTopic(&con)
|
|
|
|
}
|
2018-11-12 14:07:34 +03:00
|
|
|
conf.UpdateDocs(&con)
|
2018-11-11 11:59:58 +03:00
|
|
|
}
|