Exemple #1
0
func (r *esAliases) Run() error {
	m, e := indexAliases(r.Host)
	if e != nil {
		return e
	}
	t := gocli.NewTable()
	for name, a := range m {
		aliases := []string{}
		for k := range a.Aliases {
			aliases = append(aliases, k)
		}
		t.Add(name, strings.Join(aliases, ", "))
	}
	fmt.Println(t)
	return nil
}
Exemple #2
0
func (r *esIndexes) Run() error {
	idx := &es.Index{Host: r.Host}
	parts := strings.Split(r.Host, ":")
	idx.Host = parts[0]
	var err error
	if len(parts) > 1 {
		idx.Port, err = strconv.Atoi(parts[1])
		if err != nil {
			return err
		}
	}
	stats, e := idx.Stats()
	if e != nil {
		return e
	}
	names := stats.IndexNames()
	if r.Compact {
		for _, n := range names {
			fmt.Println(n)
		}
		return nil
	}
	t := gocli.NewTable()
	if len(names) < 1 {
		logger.Printf("no indexes found")
		return nil
	}
	t.Add("name", "docs", "size")
	sort.Strings(names)
	for _, name := range names {
		index := stats.Indices[name]
		t.Add(name, index.Total.Docs.Count, sizePretty(index.Total.Store.SizeInBytes))
	}
	fmt.Println(t)
	return nil
}