<?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 Why does the map command return no results? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-map-command-return-no-results/m-p/334863#M99530</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;

&lt;P&gt;I have a use case where I need to iterate over multiple query strings and execute each of them, so I though of using the map command and passing the search query as a token to the map search like this&lt;BR /&gt;
   &lt;CODE&gt;| makeresults count=1| eval query = "| makeresults count=1 | eval test=\"Hello\"" | map search="$query$" maxsearches=1&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This search won't return any results. However if I put the search string directly in the mapping command I get the expected results&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| makeresults count=1| eval query = "" | map search="| makeresults count=1 | eval test=\"Hello\"" maxsearches=1&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I thought that field values can be passed in mapping commands replacing their respective token. Although this is happening, the map command does not seem to execute the string as a query. &lt;/P&gt;

&lt;P&gt;Does someone has an explanation for this behavior and maybe even a solution?&lt;/P&gt;</description>
    <pubDate>Wed, 07 Mar 2018 20:35:15 GMT</pubDate>
    <dc:creator>bojanisch</dc:creator>
    <dc:date>2018-03-07T20:35:15Z</dc:date>
    <item>
      <title>Why does the map command return no results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-map-command-return-no-results/m-p/334863#M99530</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;

&lt;P&gt;I have a use case where I need to iterate over multiple query strings and execute each of them, so I though of using the map command and passing the search query as a token to the map search like this&lt;BR /&gt;
   &lt;CODE&gt;| makeresults count=1| eval query = "| makeresults count=1 | eval test=\"Hello\"" | map search="$query$" maxsearches=1&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This search won't return any results. However if I put the search string directly in the mapping command I get the expected results&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| makeresults count=1| eval query = "" | map search="| makeresults count=1 | eval test=\"Hello\"" maxsearches=1&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I thought that field values can be passed in mapping commands replacing their respective token. Although this is happening, the map command does not seem to execute the string as a query. &lt;/P&gt;

&lt;P&gt;Does someone has an explanation for this behavior and maybe even a solution?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 20:35:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-map-command-return-no-results/m-p/334863#M99530</guid>
      <dc:creator>bojanisch</dc:creator>
      <dc:date>2018-03-07T20:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the map command return no results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-map-command-return-no-results/m-p/334864#M99531</link>
      <description>&lt;P&gt;Okay after some more research I found out that Splunk isn't parsing the token as a query, but as a string. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;03-07-2018 21:49:45.182 INFO  SearchParser - PARSING: search "| makeresults count=1 | eval test=\"Hello\""&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;After passing the string through a macro, everything works as expected&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| makeresults count=1| eval query = "| makeresults count=1 | eval test=\"Hello\"" | map search="`getSearchAsString($query$)`" maxsearches=1&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;where the macro is defined as &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[getSearchAsString(1)]
args = search
definition = $search$
iseval = 0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Mar 2018 21:06:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-map-command-return-no-results/m-p/334864#M99531</guid>
      <dc:creator>bojanisch</dc:creator>
      <dc:date>2018-03-07T21:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the map command return no results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-map-command-return-no-results/m-p/334865#M99532</link>
      <description>&lt;P&gt;I think because you had quotes in query variable, you could have trimmed them&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 09:17:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-map-command-return-no-results/m-p/334865#M99532</guid>
      <dc:creator>valiquet</dc:creator>
      <dc:date>2018-03-09T09:17:11Z</dc:date>
    </item>
  </channel>
</rss>

