code: func (s *server) Query(c context.Context, req *logdog.QueryRequest) (*logdog.QueryResponse, error) {
  	// Non-admin users may not request purged results.
  	canSeePurged := true
  	if err := coordinator.IsAdminUser(c); err != nil {
  		canSeePurged = false
  
  		// Non-admin user.
  		if req.Purged == logdog.QueryRequest_YES {
  			log.Fields{
  				log.ErrorKey: err,
  			}.Errorf(c, "Non-superuser requested to see purged logs. Denying.")
  			return nil, grpcutil.Errf(codes.InvalidArgument, "non-admin user cannot request purged log streams")
  		}
  	}
  
  	// Scale the maximum number of results based on the number of queries in this
  	// request. If the user specified a maximum result count of zero, use the
  	// default maximum.
  	//
  	// If this scaling results in a limit that is <1 per request, we will return
  	// back a BadRequest error.
  	limit := s.resultLimit
  	if limit == 0 {
  		limit = queryResultLimit
  	}
  
  	// Execute our queries in parallel.
  	resp := logdog.QueryResponse{}
  	e := &queryRunner{
  		Context:      log.SetField(c, "path", req.Path),
  		QueryRequest: req,
  		canSeePurged: canSeePurged,
  		limit:        limit,
  	}
  
  	startTime := clock.Now(c)
  	if err := e.runQuery(&resp); err != nil {
  		// Transient errors would be handled at the "execute" level, so these are
  		// specific failure errors. We must escalate individual errors to the user.
  		// We will choose the most severe of the resulting errors.
  		log.WithError(err).Errorf(c, "Failed to execute query.")
  		return nil, err
  	}
  	log.Infof(c, "Query took: %s", clock.Now(c).Sub(startTime))
  	return &resp, nil
  }
docs: // Query returns log stream paths that match the requested query.