<?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 the search results disappear / how to keep them longer (python SDK) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/the-search-results-disappear-how-to-keep-them-longer-python-SDK/m-p/77472#M19563</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I'm writing a cron job (using the Python SDK) that does a search and exports the data to a CSV file (to analyze it in a different app). The result usually is a few hundreds thousands rows (~ a million or so), so I need to fetch it piecewise (by 50k). The problem is that sometimes the result suddenly disappears after fetching the first few segments.&lt;/P&gt;

&lt;P&gt;How to get rid of that? Is there an option to mark a result as 'do not remove' or something like that?&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jun 2012 08:45:18 GMT</pubDate>
    <dc:creator>tomasv</dc:creator>
    <dc:date>2012-06-18T08:45:18Z</dc:date>
    <item>
      <title>the search results disappear / how to keep them longer (python SDK)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/the-search-results-disappear-how-to-keep-them-longer-python-SDK/m-p/77472#M19563</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I'm writing a cron job (using the Python SDK) that does a search and exports the data to a CSV file (to analyze it in a different app). The result usually is a few hundreds thousands rows (~ a million or so), so I need to fetch it piecewise (by 50k). The problem is that sometimes the result suddenly disappears after fetching the first few segments.&lt;/P&gt;

&lt;P&gt;How to get rid of that? Is there an option to mark a result as 'do not remove' or something like that?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2012 08:45:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/the-search-results-disappear-how-to-keep-them-longer-python-SDK/m-p/77472#M19563</guid>
      <dc:creator>tomasv</dc:creator>
      <dc:date>2012-06-18T08:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: the search results disappear / how to keep them longer (python SDK)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/the-search-results-disappear-how-to-keep-them-longer-python-SDK/m-p/77473#M19564</link>
      <description>&lt;P&gt;Great question tomasv! The real answer has to do with the TTL of the search job. The default value is 600, and it unfortunately does not get reset when you get results from the job. You have a few options:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;You can call &lt;CODE&gt;my_job.touch()&lt;/CODE&gt; after every call to &lt;CODE&gt;my_job.results(...)&lt;/CODE&gt; - that will reset the TTL.&lt;/LI&gt;
&lt;LI&gt;You can explicitly set a longer TTL with `my_job.set_ttl(6000)' (or some other number, of course).&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;The other thing to note is that if you truly have hundreds of thousands of rows you need to get out of a single search, you may be better suited with using the &lt;CODE&gt;search/jobs/export&lt;/CODE&gt; endpoint. In the Python SDK, you can take a look at the export sample &lt;A href="https://github.com/splunk/splunk-sdk-python/tree/master/examples/export" target="_blank"&gt;here&lt;/A&gt;, which shows you how to do it. The benefit of the export endpoint is that it will simply stream the results to you as they are ready, so you don't have to keep paginating. You might find that this is a faster mechanism.&lt;/P&gt;

&lt;P&gt;Let me know if this makes sense, and if not, I can add some more details.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:03:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/the-search-results-disappear-how-to-keep-them-longer-python-SDK/m-p/77473#M19564</guid>
      <dc:creator>ineeman</dc:creator>
      <dc:date>2020-09-28T12:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: the search results disappear / how to keep them longer (python SDK)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/the-search-results-disappear-how-to-keep-them-longer-python-SDK/m-p/77474#M19565</link>
      <description>&lt;P&gt;Great answer ineeman! I haven't tried the export endpoint yet, but the touch() seems to be working just fine.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2012 09:21:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/the-search-results-disappear-how-to-keep-them-longer-python-SDK/m-p/77474#M19565</guid>
      <dc:creator>tomasv</dc:creator>
      <dc:date>2012-08-09T09:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: the search results disappear / how to keep them longer (python SDK)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/the-search-results-disappear-how-to-keep-them-longer-python-SDK/m-p/77475#M19566</link>
      <description>&lt;P&gt;thanks - let us know if you need anything else. Also, don't forget to select an answer.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2012 15:21:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/the-search-results-disappear-how-to-keep-them-longer-python-SDK/m-p/77475#M19566</guid>
      <dc:creator>ineeman</dc:creator>
      <dc:date>2012-08-09T15:21:40Z</dc:date>
    </item>
  </channel>
</rss>

