<?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 Re: Only 100 Results return with python API query in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39491#M485</link>
    <description>&lt;P&gt;Hi wibbs,&lt;/P&gt;

&lt;P&gt;I did this way and worked fine to me.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;kwargs_options = {"count" : 0}&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;response = service.job(sid).results(**kwargs_options)&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Jul 2016 15:04:20 GMT</pubDate>
    <dc:creator>rafamss</dc:creator>
    <dc:date>2016-07-01T15:04:20Z</dc:date>
    <item>
      <title>Only 100 Results return with python API query</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39486#M480</link>
      <description>&lt;P&gt;Hello there,&lt;BR /&gt;
I'm still newer to Splunk (and python which doesn't help). I used the code from the search and poll results code on the sdk page.  I can't seem to figure out how to get more than 100 results. Here's the code&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#set login settings above    
kwargs_normalsearch = {"exec_mode": "normal", "max_count" : "20000"}

searchquery_normal = "search *"
job = service.jobs.create(searchquery_normal,  **kwargs_normalsearch)

# A normal search returns the job's SID right away, so we need to poll for completion
while True:
    job.refresh()
    stats = {"isDone": job["isDone"],
             #"doneProgress": float(job["doneProgress"])*100,
              #"scanCount": int(job["scanCount"]),
              "eventCount": int(job["eventCount"]),
              "resultCount": int(job["resultCount"])}
    #status = ("\r%(doneProgress)03.1f%%   %(scanCount)d scanned   "
    status =("\r%(eventCount)d matched   %(resultCount)d results") % stats

    sys.stdout.write(status)
    sys.stdout.flush()
    if stats["isDone"] == "1":
        sys.stdout.write("\n\nDone!\n\n")
        break
    sleep(2)

# Get properties of the job
print "Search job properties"
print "Search job ID:        ", job["sid"]
print "The number of events: ", job["eventCount"]
print "The number of results:", job["resultCount"]
print "Search duration:      ", job["runDuration"], "seconds"
print "This job expires in:  ", job["ttl"], "seconds"
print "------------------------------------------\n"
print "Search results:\n"

num_results=0
# Get the results and display them
newFile = open("splunkResults.txt", 'w')

x = 0
for result in results.ResultsReader(job.results()):
    x += 1
    print x
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;x always ends up being 100. (see bottom of code). I'm assuming i'm just over looking something but i can't figure out for the life of me what it is.&lt;/P&gt;

&lt;P&gt;forgot to give you the output of the script&lt;/P&gt;

&lt;P&gt;OUTPUT:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;5000 matched   5000 results

Done!

Search job properties
Search job ID:         1376943997.140464
The number of events:  5000
The number of results: 5000
Search duration:       127.888000 seconds
This job expires in:   150000 seconds

Search results:

100
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Aug 2013 20:34:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39486#M480</guid>
      <dc:creator>wibbs</dc:creator>
      <dc:date>2013-08-19T20:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Only 100 Results return with python API query</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39487#M481</link>
      <description>&lt;P&gt;46 views and no idea's?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2013 16:37:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39487#M481</guid>
      <dc:creator>wibbs</dc:creator>
      <dc:date>2013-08-20T16:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: Only 100 Results return with python API query</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39488#M482</link>
      <description>&lt;P&gt;Should have read a bit closer. I thought this was a kwargs issue, but turns out it's probably a splunk config issue. Anyway, i used this - &lt;A href="http://dev.splunk.com/view/SP-CAAAEE5#paginating"&gt;http://dev.splunk.com/view/SP-CAAAEE5#paginating&lt;/A&gt; to get more than 100 results.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2013 20:57:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39488#M482</guid>
      <dc:creator>wibbs</dc:creator>
      <dc:date>2013-08-20T20:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Only 100 Results return with python API query</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39489#M483</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;Try Below:&lt;/P&gt;

&lt;P&gt;kwargs_normalsearch = {"exec_mode": "normal", "count" : 10000}&lt;/P&gt;

&lt;P&gt;for result in results.ResultsReader(job.results(**kwargs_normalsearch)):&lt;BR /&gt;
    x += 1&lt;BR /&gt;
    print x&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:41:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39489#M483</guid>
      <dc:creator>himanshusinha1</dc:creator>
      <dc:date>2020-09-28T14:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Only 100 Results return with python API query</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39490#M484</link>
      <description>&lt;P&gt;Solved: &lt;STRONG&gt;job.results(count=0)&lt;/STRONG&gt; fixed it for me. &lt;/P&gt;

&lt;P&gt;In my case splunk seems to completely ignore the count variable. I have it set to 1 or 10000, it will always return 100. &lt;/P&gt;

&lt;P&gt;From the log...&lt;/P&gt;

&lt;P&gt;POST request to &lt;A href="https://XXXXXXX:8089/services/search/jobs/"&gt;https://XXXXXXX:8089/services/search/jobs/&lt;/A&gt; (body: {&lt;STRONG&gt;'count': 10000,&lt;/STRONG&gt; 'search_mode': 'normal', 'search': 'search index = myindex earliest=-30m'})  &lt;/P&gt;

&lt;P&gt;Still returns 100. The job["resultCount"] value says there are &lt;STRONG&gt;549&lt;/STRONG&gt; results.&lt;/P&gt;

&lt;P&gt;If I go to the search job id site &lt;/P&gt;

&lt;P&gt;&lt;A href="https://XXXXXXX:8089/services/search/jobs/1466455902.9551_2288E5C9-03DA-4BDF-AE92-735977C5CE06/results"&gt;https://XXXXXXX:8089/services/search/jobs/1466455902.9551_2288E5C9-03DA-4BDF-AE92-735977C5CE06/results&lt;/A&gt; the &lt;STRONG&gt;result offset&lt;/STRONG&gt; goes from 0 to 99. So it is just reading from that unfortunately. &lt;/P&gt;

&lt;P&gt;If this is due to limits.conf - what exact variable must be updated? &lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2016 21:03:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39490#M484</guid>
      <dc:creator>ifeldshteyn</dc:creator>
      <dc:date>2016-06-20T21:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Only 100 Results return with python API query</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39491#M485</link>
      <description>&lt;P&gt;Hi wibbs,&lt;/P&gt;

&lt;P&gt;I did this way and worked fine to me.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;kwargs_options = {"count" : 0}&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;response = service.job(sid).results(**kwargs_options)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 15:04:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39491#M485</guid>
      <dc:creator>rafamss</dc:creator>
      <dc:date>2016-07-01T15:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Only 100 Results return with python API query</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39492#M486</link>
      <description>&lt;P&gt;This also fixed the issue I was having. Thank you!&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2017 20:44:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Only-100-Results-return-with-python-API-query/m-p/39492#M486</guid>
      <dc:creator>cegoes</dc:creator>
      <dc:date>2017-04-16T20:44:01Z</dc:date>
    </item>
  </channel>
</rss>

