SPLK-2001 practice question 15 of 15

Which of these URLs could be used to construct a REST request to search the employee KV store collection to find records with a rating greater than or equal to 2 and less than 5?

Full set: 66 questions
Answer options
A: ‘http://localhost:8089/servicesNS/nobody/search/storage/collections/data/ employees?query={$and:[{rating:{$gte:2}},{rating:{$lt:5}}]}&output_mode-json’
B: ‘http://localhost:8089/servicesNS/nobody/search/storage/collections/data/ employees?query={$and:[{rating:$gte:2}},{rating:{$lt:5}}]}&output_mode=json’
C: ‘http://localhost:8089/servicesNS/nobody/search/storage/collections/data/ employees?query={%22rating%22:{%22$gte%22:2}},{%22$and%22},{%22rating%22:{% 22$lt%22:5}}}&output_mode=json’
D: ‘http://localhost:8089/servicesNS/nobody/search/storage/collections/data/ employees?query={%22$and%22:[{%22rating%22:{%22$gte%22:2}},{%22rating%22:{% 22$lt%22:5}}]}&output_mode=json’ Correct answer
Correct Answer:
D. ‘http://localhost:8089/servicesNS/nobody/search/storage/collections/data/ employees?query={%22$and%22:[{%22rating%22:{%22$gte%22:2}},{%22rating%22:{% 22$lt%22:5}}]}&output_mode=json’
Explanation

The correct URL must use the KV Store REST API endpoint and provide a valid, URL-encoded, MongoDB-style query. The query needs to combine two conditions using a logical $and operator: rating is greater than or equal to 2 ($gte: 2) and rating is less than 5 ($lt: 5). Option D correctly constructs this query as a JSON object {"$and":[{"rating":{"$gte":2}},{"rating":{"$lt":5}}]} and properly URL-encodes it for use as a query parameter. The base endpoint and outputmode parameter are also correct.

Why Incorrect

A. This option is not URL-encoded, which is required for special characters in a URL. It also uses an invalid parameter outputmode-json (with a hyphen instead of an equals sign).
B. The JSON syntax for the query is invalid. The first condition rating:$gte:2 is missing the required curly braces {} around the $gte:2 part, making it un-parsable.
C. The decoded JSON query {"rating":{"$gte":2}},{"$and"},{"rating":{"$lt":5}}} is structurally incorrect. The $and operator must be a key whose value is an array of the conditions to be joined.

References

1. Splunk REST API Reference Manual: The documentation for the storage/collections/data/{collection} endpoint specifies the use of the query parameter to filter results. It states

"The query parameter must be a URL-encoded

JSON-formatted

MongoDB-style query."

Source: Splunk Enterprise 9.2.1

REST API Reference Manual

"storage/collections/data/{collection}" endpoint documentation

Parameters section.

2. Splunk Developer Guide: This guide provides examples and details on using the KV Store

including the syntax for queries. The query syntax is based on MongoDB

where the logical $and operator takes an array of condition documents. The structure {$and: [ { }

{ } ]} is the correct format.

Source: Splunk Developer Guide

Use the KV Store REST API

"Retrieve records from a collection" section. This section details the query parameter and its MongoDB-style JSON format.

Scroll to Top