<?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: How to create a subsearch with multiple results? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413984#M119290</link>
    <description>&lt;P&gt;ARGH!  Yes, you are right (I edited and fixed that, too).  I was using a run-anywhere search to test but forgot to convert that part when I posted the answer.  Thank you for grading my papers.&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jun 2019 14:56:26 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-06-14T14:56:26Z</dc:date>
    <item>
      <title>How to create a subsearch with multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413978#M119284</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I've a question about sub search, I'm probably misunderstanding docs and other posts.&lt;/P&gt;

&lt;P&gt;This is my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=MyIndex [ search index=MyIndex host=as-x | rex " info about (?[A-Z0-9]+)"| rename objectId as search  ] stringFilter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The subsearch, executed as a normal search, produce many results, so many objectId.&lt;/P&gt;

&lt;P&gt;My expectations is that the final search is like this below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=MyIndex (objectId-1 OR objectId-2 OR objectId-3)  stringFilter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The behavior is different, only one objectId is used to search and the final search is similar to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=MyIndex (objectId-1)  stringFilter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I don't understand why and what I need to change in order to process all objects of subsearch resultset.&lt;/P&gt;

&lt;P&gt;Thanks for any kind help&lt;/P&gt;

&lt;P&gt;Marcello&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 07:07:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413978#M119284</guid>
      <dc:creator>trucall</dc:creator>
      <dc:date>2019-06-12T07:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subsearch with multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413979#M119285</link>
      <description>&lt;P&gt;Probably because your subsearch does not have any transforming commands. I think the following should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=MyIndex [ search index=MyIndex host=as-x | rex " info about (?&amp;lt;objectId&amp;gt;[A-Z0-9]+)"| stats values(objectId) as search | eval search = mvjoin(search," OR ") ] stringFilter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note: if you make sure objectId is properly extracted (so you don't need rex for it), you can simply do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=MyIndex [ search index=MyIndex host=as-x | fields objectId | dedup objectId | format ] stringFilter
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jun 2019 12:53:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413979#M119285</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-06-12T12:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subsearch with multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413980#M119286</link>
      <description>&lt;P&gt;You are taking over too much control and doing it all wrong.  Start with this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=MyIndex host=as-x | rex " info about (?[A-Z0-9]+)" | stats count BY objectId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See what this produces and then switch to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=MyIndex host=as-x | rex " info about (?[A-Z0-9]+)" | stats count BY objectId | fields - count | format
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See what this produces and then switch to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=MyIndex host=as-x | rex " info about (?[A-Z0-9]+)" | stats count BY objectId | fields - count | format "(" "" "" "" "OR" ")" | rex field=search mode=sed "s/objectId =//g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See what this produces and then switch to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=MyIndex [ search index=MyIndex host=as-x | rex " info about (?[A-Z0-9]+)" | stats count BY objectId | fields - count | format "(" "" "" "" "OR" ")" | rex field=search mode=sed "s/objectId =//g" ] stringFilter
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jun 2019 22:11:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413980#M119286</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-12T22:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subsearch with multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413981#M119287</link>
      <description>&lt;P&gt;Using format will result in the subsearch returning something like &lt;CODE&gt;(objectId="123" OR objectId="456")&lt;/CODE&gt;, which wont work given that objectId apparently is not an extracted field. He wants the subsearch to only return the values, to then work as a string filter.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 07:07:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413981#M119287</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-06-13T07:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subsearch with multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413982#M119288</link>
      <description>&lt;P&gt;Ah, based on this clarification, I have modified my original answer above.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 21:21:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413982#M119288</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-13T21:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subsearch with multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413983#M119289</link>
      <description>&lt;P&gt;I trust you meant &lt;CODE&gt;| rex field=search mode=sed "s/objectId=//g"&lt;/CODE&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 06:28:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413983#M119289</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-06-14T06:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subsearch with multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413984#M119290</link>
      <description>&lt;P&gt;ARGH!  Yes, you are right (I edited and fixed that, too).  I was using a run-anywhere search to test but forgot to convert that part when I posted the answer.  Thank you for grading my papers.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 14:56:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413984#M119290</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-14T14:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subsearch with multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413985#M119291</link>
      <description>&lt;P&gt;Yo mcfly, @trucall, we've got answers for you, did anything work?&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jun 2019 22:20:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-subsearch-with-multiple-results/m-p/413985#M119291</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-15T22:20:31Z</dc:date>
    </item>
  </channel>
</rss>

