add index fields filter flags (#27)

This commit is contained in:
T. von Dein
2026-06-03 10:14:41 +02:00
parent 18af1b6073
commit 5ecba5abe6
3 changed files with 37 additions and 4 deletions

View File

@@ -21,6 +21,7 @@ import (
"fmt"
"log/slog"
"regexp"
"slices"
"strconv"
"strings"
"time"
@@ -311,17 +312,26 @@ func IndexFields(conf *cfg.Config, index string) error {
return fmt.Errorf("failed to retrieve field capabilties: %s", esErrorString(err))
}
table := printer.NewTable(conf, 5, len(res.Fields))
table := printer.NewTable(conf, 5, 0)
table.Addheaders("field", "type", "searchable", "aggretable", "metadata")
idx := 0
for name, field := range res.Fields {
for fieldtype, caps := range field {
// fields only have 1 type, so this one is it
table.Entries[idx] = []string{name, fieldtype,
switch {
case conf.Searchable && !caps.Searchable:
continue
case conf.Aggretable && !caps.Aggregatable:
continue
case len(conf.Filter) > 0 && !slices.Contains(conf.Filter, fieldtype):
continue
}
table.Entries = append(table.Entries, []string{name, fieldtype,
fmt.Sprintf("%t", caps.Searchable),
fmt.Sprintf("%t", caps.Aggregatable),
fmt.Sprintf("%t", *caps.MetadataField)}
fmt.Sprintf("%t", *caps.MetadataField)})
break
}