<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to preview partial job results in JavaScript SDK? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-to-preview-partial-job-results-in-JavaScript-SDK/m-p/315194#M4328</link>
    <description>&lt;P&gt;Hey!&lt;BR /&gt;
I'm trying to run a search in the JS Splunk SDK, and periodically check the job for the current results. I found out that there are multiple &lt;CODE&gt;exec_mode&lt;/CODE&gt;s possible, and if I set it to &lt;CODE&gt;normal&lt;/CODE&gt;, I can get the job ID before the search has ended.&lt;BR /&gt;
I tried to run my job this way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;service.search(
  searchQuery,
  searchParams,
  async function (err, job) {
    console.log("...done!\n");
    let count = 0;
    const sleep = ms =&amp;gt; new Promise(resolve =&amp;gt; setTimeout(resolve, ms))
    await sleep(4000);
    job.preview({}, function (err, results) {
      if (err) {
        console.error(err)
        return;
      }
      if (results.rows) {
        count++;
        console.log("========== Iteration " + count + " ==========");
        console.log(results.rows)
        for (var i = 0; i &amp;lt; results.rows.length; i++) {
          var row = results.rows[i];
          console.log(stat + row[countIndex]);
        }
        console.log("=================================");
      }
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with these properties:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;const searchQuery = "search index=*";
const searchParams = {
  exec_mode: "normal"
};
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The output of this &lt;CODE&gt;job.preview&lt;/CODE&gt; is that there are no rows yet.&lt;/P&gt;

&lt;P&gt;Is there anything wrong with the way I'm checking the job results? Is there a way to achieve the results before the job ends?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 05 Apr 2018 21:46:34 GMT</pubDate>
    <dc:creator>omerl</dc:creator>
    <dc:date>2018-04-05T21:46:34Z</dc:date>
    <item>
      <title>How to preview partial job results in JavaScript SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-preview-partial-job-results-in-JavaScript-SDK/m-p/315194#M4328</link>
      <description>&lt;P&gt;Hey!&lt;BR /&gt;
I'm trying to run a search in the JS Splunk SDK, and periodically check the job for the current results. I found out that there are multiple &lt;CODE&gt;exec_mode&lt;/CODE&gt;s possible, and if I set it to &lt;CODE&gt;normal&lt;/CODE&gt;, I can get the job ID before the search has ended.&lt;BR /&gt;
I tried to run my job this way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;service.search(
  searchQuery,
  searchParams,
  async function (err, job) {
    console.log("...done!\n");
    let count = 0;
    const sleep = ms =&amp;gt; new Promise(resolve =&amp;gt; setTimeout(resolve, ms))
    await sleep(4000);
    job.preview({}, function (err, results) {
      if (err) {
        console.error(err)
        return;
      }
      if (results.rows) {
        count++;
        console.log("========== Iteration " + count + " ==========");
        console.log(results.rows)
        for (var i = 0; i &amp;lt; results.rows.length; i++) {
          var row = results.rows[i];
          console.log(stat + row[countIndex]);
        }
        console.log("=================================");
      }
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with these properties:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;const searchQuery = "search index=*";
const searchParams = {
  exec_mode: "normal"
};
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The output of this &lt;CODE&gt;job.preview&lt;/CODE&gt; is that there are no rows yet.&lt;/P&gt;

&lt;P&gt;Is there anything wrong with the way I'm checking the job results? Is there a way to achieve the results before the job ends?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 21:46:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-preview-partial-job-results-in-JavaScript-SDK/m-p/315194#M4328</guid>
      <dc:creator>omerl</dc:creator>
      <dc:date>2018-04-05T21:46:34Z</dc:date>
    </item>
  </channel>
</rss>

