mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 07:54:17 +02:00
fix search output order (last on bottom) and index ls output partials (#30)
This commit is contained in:
@@ -53,15 +53,24 @@ func IndexNames(conf *cfg.Config) ([]string, error) {
|
||||
}
|
||||
|
||||
func filterIndices(conf *cfg.Config, list indices.Response) indices.Response {
|
||||
// apply partials filter first
|
||||
selectedlist := indices.Response{}
|
||||
for _, index := range list {
|
||||
if !conf.Partials && strings.HasPrefix(*index.Index, "partial-") {
|
||||
continue
|
||||
}
|
||||
selectedlist = append(selectedlist, index)
|
||||
}
|
||||
|
||||
if len(conf.Filter) == 0 {
|
||||
return list
|
||||
return selectedlist
|
||||
}
|
||||
|
||||
// we support just one filter here, for now
|
||||
filter := *regexp.MustCompile(conf.Filter[0])
|
||||
newlist := indices.Response{}
|
||||
|
||||
for _, index := range list {
|
||||
for _, index := range selectedlist {
|
||||
if filter.MatchString(*index.Index) {
|
||||
newlist = append(newlist, index)
|
||||
}
|
||||
|
||||
@@ -99,9 +99,7 @@ func searchOnce(conf *cfg.Config, search *search.Search) error {
|
||||
|
||||
slog.Debug("ES result", "search", res)
|
||||
|
||||
for _, hit := range res.Hits.Hits {
|
||||
printer.PrintDoc(conf, hit)
|
||||
}
|
||||
printer.PrintDocs(conf, res.Hits.Hits)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -141,9 +139,7 @@ func searchPit(conf *cfg.Config, req *search.Request) error {
|
||||
break
|
||||
}
|
||||
|
||||
for _, hit := range res.Hits.Hits {
|
||||
printer.PrintDoc(conf, hit)
|
||||
}
|
||||
printer.PrintDocs(conf, res.Hits.Hits)
|
||||
|
||||
last := res.Hits.Hits[len(res.Hits.Hits)-1]
|
||||
search = search.SearchAfterValues(last.Sort)
|
||||
@@ -178,6 +174,7 @@ func searchTail(conf *cfg.Config, search *search.Search) error {
|
||||
}
|
||||
|
||||
printer.PrintDoc(conf, hit)
|
||||
fmt.Println()
|
||||
|
||||
docs[*hit.Id_] = 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user