Skip to content

Commit

Permalink
feat(spctl): Search props fix
Browse files Browse the repository at this point in the history
  • Loading branch information
koltyakov committed Apr 17, 2023
1 parent aec91df commit 8236d4f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/spctl/search.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"fmt"

"github.com/AlecAivazis/survey/v2"
"github.com/koltyakov/gosip/api"
)
Expand Down Expand Up @@ -68,8 +70,14 @@ func getSearchConf(sp *api.SP) (SearchConf, error) {
return searchConf, err
}

rows := res.Data().PrimaryQueryResult.RelevantResults.Table.Rows
if len(rows) == 0 {
fmt.Println("Warning: no results found for the query")
return searchConf, nil
}

searchProps := []string{}
for _, prop := range res.Data().PrimaryQueryResult.RelevantResults.Table.Rows[0].Cells {
for _, prop := range rows[0].Cells {
propName := prop.Key
searchProps = append(searchProps, propName)
}
Expand Down

0 comments on commit 8236d4f

Please sign in to comment.