shamrickus commented on a change in pull request #5980:
URL: https://github.com/apache/trafficcontrol/pull/5980#discussion_r665326023



##########
File path: 
traffic_ops/traffic_ops_golang/trafficvault/backends/riaksvc/riak_services.go
##########
@@ -394,31 +394,54 @@ func withCluster(tx *sql.Tx, authOpts *riak.AuthOptions, 
riakPort *uint, f func(
 
 // search searches Riak for the given query. Returns nil and a nil error if no 
object was found.
 // If fields is empty, all fields will be returned.
-func search(cluster StorageCluster, index string, query string, filterQuery 
string, numRows int, fields []string) ([]*riak.SearchDoc, error) {
-       riakCmd := riak.NewSearchCommandBuilder().
-               WithIndexName(index).
-               WithQuery(query).
-               WithNumRows(uint32(numRows))
-       if len(filterQuery) > 0 {
-               riakCmd = riakCmd.WithFilterQuery(filterQuery)
-       }
-       if len(fields) > 0 {
-               riakCmd = riakCmd.WithReturnFields(fields...)
-       }
-       iCmd, err := riakCmd.Build()
+func search(cluster StorageCluster, index string, query string, filterQuery 
string, numRows uint32, fields []string) ([]*riak.SearchDoc, error) {
+       var searchDocs []*riak.SearchDoc
+       for start := uint32(0); ; start += numRows {
+               riakCmd := riak.NewSearchCommandBuilder().
+                       WithIndexName(index).
+                       WithQuery(query).
+                       WithNumRows(numRows).
+                       WithStart(start)
+               if len(filterQuery) > 0 {
+                       riakCmd = riakCmd.WithFilterQuery(filterQuery)
+               }
+               if len(fields) > 0 {
+                       riakCmd = riakCmd.WithReturnFields(fields...)
+               }
+               iCmd, err := riakCmd.Build()
 
-       if err != nil {
-               return nil, errors.New("building Riak command: " + err.Error())
-       }
-       if err = cluster.Execute(iCmd); err != nil {
-               return nil, errors.New("executing Riak command index '" + index 
+ "' query '" + query + "': " + err.Error())
-       }
-       cmd, ok := iCmd.(*riak.SearchCommand)
-       if !ok {
-               return nil, fmt.Errorf("Riak command unexpected type %T", iCmd)
-       }
-       if cmd.Response == nil || cmd.Response.NumFound == 0 {
-               return nil, nil
+               if err != nil {
+                       return nil, errors.New("building Riak command: " + 
err.Error())
+               }
+               if err = cluster.Execute(iCmd); err != nil {
+                       return nil, errors.New("executing Riak command index '" 
+ index + "' query '" + query + "': " + err.Error())
+               }
+               cmd, ok := iCmd.(*riak.SearchCommand)
+               if !ok {
+                       return nil, fmt.Errorf("riak command unexpected type 
%T", iCmd)
+               }
+               if cmd.Response == nil {
+                       return nil, fmt.Errorf("riak recieved nil responce")

Review comment:
       What, you've never seen it spelled "responce"!? :laughing: 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to