Added an optional parameter for specifying the maximum number of result elements for a query