我使用以下代码发出已保存的搜索请求。我得到输出为JSON_ROWS格式。我想以JSON或XML格式获得结果。我可以在请求中指定预期的输出格式吗?
// The saved search created earlier
var searchName = "test";
// Retrieve the saved search collection
var mySavedSearches = service.savedSearches();
mySavedSearches.init(service, {app:"-"});
mySavedSearches.fetch(function(err, mySavedSearches) {
// Retrieve the saved search that was created earlier
var mySavedSearch = mySavedSearches.item(searchName);
// Run the saved search and poll for completion
mySavedSearch.dispatch({"args.splunkCMD": searchCommand}, function(err, job) {
// Display the job's search ID
sails.log("SplunkController::executeGenericSplunkRequest() Job SID: ", job.sid);
// Poll the status of the search job
job.track({
period: 200
}, {
done: function(job) {
sails.log("SplunkController::executeGenericSplunkRequest() Splunk request completed!");
// Get 10 results and print them
job.results({
count: 10
}, function(err, results, job) {
sails.log("SplunkController::executeGenericSplunkRequest() results = " +JSON.stringify(results, null, 2));
callback(results);
});
},
failed: function(job) {
console.log("Job failed")
},
error: function(err) {
done(err);
}
});
});
});