2

我使用以下代码进行保存的搜索请求。我得到 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);
               }
             });
           });
         });
4

0 回答 0