client/splunk.js
function(fieldName, sortAttribute, sortDirection, limit, statsFunction) {
            if (!this.dataModelObject.hasField(fieldName)) {
                throw new Error("Cannot add limit filter on a nonexistent field.");
            }

            var f = this.dataModelObject.fieldByName(fieldName);

            if (!utils.contains(["string", "number", "objectCount"], f.type)) {
                throw new Error("Cannot add limit filter on " + fieldName + " because it is of type " + f.type);
            }

            if ("string" === f.type && !utils.contains(["count", "dc"], statsFunction)) {
                throw new Error("Stats function for fields of type string must be COUNT or DISTINCT_COUNT; found " +
                    statsFunction);
            }

            if ("number" === f.type && !utils.contains(["count", "dc", "average", "sum"], statsFunction)) {
                throw new Error("Stats function for fields of type number must be one of COUNT, DISTINCT_COUNT, SUM, or AVERAGE; found " +
                    statsFunction);
            }

            if ("objectCount" === f.type && !utils.contains(["count"], statsFunction)) {
                throw new Error("Stats function for fields of type object count must be COUNT; found " + statsFunction);
            }

            var filter = {
                fieldName: fieldName,
                owner: f.lineage.join("."),
                type: f.type,
                attributeName: sortAttribute,
                attributeOwner: this.dataModelObject.fieldByName(sortAttribute).lineage.join("."),
                sortDirection: sortDirection,
                limitAmount: limit,
                statsFn: statsFunction
            };
            // Assumed "highest" is preferred for when sortDirection is "DEFAULT"
            filter.limitType = "ASCENDING" === sortDirection ? "lowest" : "highest";
            this.filters.push(filter);

            return this;
        }
function(fieldName, sortAttribute, sortDirection, limit, statsFunction) {
            if (!this.dataModelObject.hasField(fieldName)) {
                throw new Error("Cannot add limit filter on a nonexistent field.");
            }

            var f = this.dataModelObject.fieldByName(fieldName);

            if (!utils.contains(["string", "number", "objectCount"], f.type)) {
                throw new Error("Cannot add limit filter on " + fieldName + " because it is of type " + f.type);
            }

            if ("string" === f.type && !utils.contains(["count", "dc"], statsFunction)) {
                throw new Error("Stats function for fields of type string must be COUNT or DISTINCT_COUNT; found " +
                    statsFunction);
            }

            if ("number" === f.type && !utils.contains(["count", "dc", "average", "sum"], statsFunction)) {
                throw new Error("Stats function for fields of type number must be one of COUNT, DISTINCT_COUNT, SUM, or AVERAGE; found " +
                    statsFunction);
            }

            if ("objectCount" === f.type && !utils.contains(["count"], statsFunction)) {
                throw new Error("Stats function for fields of type object count must be COUNT; found " + statsFunction);
            }

            var filter = {
                fieldName: fieldName,
                owner: f.lineage.join("."),
                type: f.type,
                attributeName: sortAttribute,
                attributeOwner: this.dataModelObject.fieldByName(sortAttribute).lineage.join("."),
                sortDirection: sortDirection,
                limitAmount: limit,
                statsFn: statsFunction
            };
            // Assumed "highest" is preferred for when sortDirection is "DEFAULT"
            filter.limitType = "ASCENDING" === sortDirection ? "lowest" : "highest";
            this.filters.push(filter);

            return this;
        }
function ( fieldName , sortAttribute , sortDirection , limit , statsFunction ) { if ( ! this . dataModelObject . hasField ( fieldName ) ) { throw new Error ( "Cannot add limit filter on a nonexistent field." ) ; } var f = this . dataModelObject . fieldByName ( fieldName ) ; if ( ! utils . contains ( [ "string" , "number" , "objectCount" ] , f . type ) ) { throw new Error ( "Cannot add limit filter on " + fieldName + " because it is of type " + f . type ) ; } if ( "string" === f . type && ! utils . contains ( [ "count" , "dc" ] , statsFunction ) ) { throw new Error ( "Stats function for fields of type string must be COUNT or DISTINCT_COUNT; found " + statsFunction ) ; } if ( "number" === f . type && ! utils . contains ( [ "count" , "dc" , "average" , "sum" ] , statsFunction ) ) { throw new Error ( "Stats function for fields of type number must be one of COUNT, DISTINCT_COUNT, SUM, or AVERAGE; found " + statsFunction ) ; } if ( "objectCount" === f . type && ! utils . contains ( [ "count" ] , statsFunction ) ) { throw new Error ( "Stats function for fields of type object count must be COUNT; found " + statsFunction ) ; } var filter = { fieldName : fieldName , owner : f . lineage . join ( "." ) , type : f . type , attributeName : sortAttribute , attributeOwner : this . dataModelObject . fieldByName ( sortAttribute ) . lineage . join ( "." ) , sortDirection : sortDirection , limitAmount : limit , statsFn : statsFunction } ; // Assumed "highest" is preferred for when sortDirection is "DEFAULT" filter . limitType = "ASCENDING" === sortDirection ? "lowest" : "highest" ; this . filters . push ( filter ) ; return this ; }
Add a limit on the events shown in a pivot by sorting them according to some field, then taking
the specified number from the beginning or end of the list.

@param {String} fieldName The name of field to filter on.
@param {String} sortAttribute The name of the field to use for sorting.
@param {String} sortDirection The direction to sort events, see class docs for valid types.
@param {String} limit The number of values from the sorted list to allow through this filter.
@param {String} statsFunction The stats function to use for aggregation before sorting, see class docs for valid types.
@return {splunkjs.Service.PivotSpecification} The updated pivot specification.

@method splunkjs.Service.PivotSpecification
Add a limit on the events shown in a pivot by sorting them according to some field then taking the specified number from the beginning or end of the list .