<?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 Understanding map command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Understanding-map-command/m-p/465410#M131116</link>
    <description>&lt;P&gt;I am banging my head trying to understand the    &lt;CODE&gt;map&lt;/CODE&gt; command and how it works. I have one search that returns values:&lt;/P&gt;

&lt;P&gt;index=offers sourcetype=offer producttype=*  earliest=-5m latest=now &lt;BR /&gt;
  | stats count by producttype&lt;BR /&gt;
  | table producttype&lt;/P&gt;

&lt;P&gt;This gives me the a set of data. So far so good.&lt;BR /&gt;
|producttype|&lt;BR /&gt;
1&lt;BR /&gt;&lt;BR /&gt;
3&lt;BR /&gt;
9&lt;BR /&gt;
12&lt;/P&gt;

&lt;P&gt;What I thought    &lt;CODE&gt;map&lt;/CODE&gt; did was to pass these $productID$ values to the 'mapped query and run it up to maxsearches time (in this case 4). So my next line was :&lt;/P&gt;

&lt;P&gt;map maxsearches=4 search = "index=offers sourcetype=offer producttype=$producttype$  earliest=-5m latest=now &lt;BR /&gt;
| timechart ...some stuff... &lt;BR /&gt;
| blah blah&lt;BR /&gt;
| etc.... "&lt;/P&gt;

&lt;P&gt;I get no results found. (This is a simplified version of my search and the foreach is not going to be an option with my final goal). What am I failing to understand? Thank you in advance!&lt;/P&gt;</description>
    <pubDate>Wed, 23 Oct 2019 23:15:23 GMT</pubDate>
    <dc:creator>mtrochym</dc:creator>
    <dc:date>2019-10-23T23:15:23Z</dc:date>
    <item>
      <title>Understanding map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-map-command/m-p/465410#M131116</link>
      <description>&lt;P&gt;I am banging my head trying to understand the    &lt;CODE&gt;map&lt;/CODE&gt; command and how it works. I have one search that returns values:&lt;/P&gt;

&lt;P&gt;index=offers sourcetype=offer producttype=*  earliest=-5m latest=now &lt;BR /&gt;
  | stats count by producttype&lt;BR /&gt;
  | table producttype&lt;/P&gt;

&lt;P&gt;This gives me the a set of data. So far so good.&lt;BR /&gt;
|producttype|&lt;BR /&gt;
1&lt;BR /&gt;&lt;BR /&gt;
3&lt;BR /&gt;
9&lt;BR /&gt;
12&lt;/P&gt;

&lt;P&gt;What I thought    &lt;CODE&gt;map&lt;/CODE&gt; did was to pass these $productID$ values to the 'mapped query and run it up to maxsearches time (in this case 4). So my next line was :&lt;/P&gt;

&lt;P&gt;map maxsearches=4 search = "index=offers sourcetype=offer producttype=$producttype$  earliest=-5m latest=now &lt;BR /&gt;
| timechart ...some stuff... &lt;BR /&gt;
| blah blah&lt;BR /&gt;
| etc.... "&lt;/P&gt;

&lt;P&gt;I get no results found. (This is a simplified version of my search and the foreach is not going to be an option with my final goal). What am I failing to understand? Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 23:15:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-map-command/m-p/465410#M131116</guid>
      <dc:creator>mtrochym</dc:creator>
      <dc:date>2019-10-23T23:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-map-command/m-p/465411#M131117</link>
      <description>&lt;P&gt;What are you trying to accomplish with the &lt;CODE&gt;map&lt;/CODE&gt; command? I've rarely run into a case where I need it over different commands&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 23:23:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-map-command/m-p/465411#M131117</guid>
      <dc:creator>aberkow</dc:creator>
      <dc:date>2019-10-23T23:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-map-command/m-p/465412#M131118</link>
      <description>&lt;P&gt;@aberkow makes a good point.  &lt;CODE&gt;map&lt;/CODE&gt; is powerful, but costly and there often are other ways to accomplish the task.  Try a subsearch.&lt;BR /&gt;
In this example, the query within brackets (the subsearch) fetches your product types.  Change the argument to &lt;CODE&gt;head&lt;/CODE&gt; to return the desired number of producttype values.  The results of the subsearch become part of the main search, like &lt;CODE&gt;index=offers sourcetype=offers (producttype=1 OR producttype=3 OR producttype=9 OR producttype=12)) earliest=-5m ...&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=offers sourcetype=offer [index=offers sourcetype=offer producttype=* earliest=-5m latest=now
| stats count by producttype | head 4
| fields producttype | format ] earliest=-5m latest=now
| timechart ...some stuff...
| blah blah
| etc.... 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Oct 2019 04:19:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-map-command/m-p/465412#M131118</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-10-24T04:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-map-command/m-p/465413#M131119</link>
      <description>&lt;P&gt;You are missing the &lt;CODE&gt;search&lt;/CODE&gt; operator just inside of the double-quotes; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=offers sourcetype=offer producttype=* earliest=-5m latest=now
| stats count by producttype
| map maxsearches=4 search="search index=offers sourcetype=offer producttype=$producttype$ earliest=-5m latest=now
| timechart ...some stuff...
| blah blah
| etc.... "
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Oct 2019 23:58:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-map-command/m-p/465413#M131119</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-25T23:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-map-command/m-p/465414#M131120</link>
      <description>&lt;P&gt;The &lt;CODE&gt;subsearch&lt;/CODE&gt; way seems to work but it is not documented as supported for a very good reason that is fairly complicated; You should stick to using &lt;CODE&gt;double-quotes&lt;/CODE&gt;.  See my answer.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 23:59:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-map-command/m-p/465414#M131120</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-25T23:59:10Z</dc:date>
    </item>
  </channel>
</rss>

