<?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: search a result and then a field value create array and pass 1 by 1 in another search query at same time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/search-a-result-and-then-a-field-value-create-array-and-pass-1/m-p/416953#M119977</link>
    <description>&lt;P&gt;And if adding to above I need that from the array list if something not present from the list how to achieve that&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jul 2019 21:08:07 GMT</pubDate>
    <dc:creator>varunawasthi9</dc:creator>
    <dc:date>2019-07-29T21:08:07Z</dc:date>
    <item>
      <title>search a result and then a field value create array and pass 1 by 1 in another search query at same time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-a-result-and-then-a-field-value-create-array-and-pass-1/m-p/416950#M119974</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;is this doable that a search request give a list of results in that a filed will have order id those are list of order ids and those need to pass 1 by 1 on next Query &lt;/P&gt;

&lt;P&gt;Eg &lt;/P&gt;

&lt;P&gt;first search gives me&lt;/P&gt;

&lt;P&gt;1 abc&lt;BR /&gt;
2 efg&lt;BR /&gt;
3 eeg&lt;/P&gt;

&lt;P&gt;from thay pass 1 by 1 in another search at the same time&lt;/P&gt;

&lt;P&gt;like index=xyz 1 create&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 19:35:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-a-result-and-then-a-field-value-create-array-and-pass-1/m-p/416950#M119974</guid>
      <dc:creator>varunawasthi9</dc:creator>
      <dc:date>2019-07-29T19:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: search a result and then a field value create array and pass 1 by 1 in another search query at same time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-a-result-and-then-a-field-value-create-array-and-pass-1/m-p/416951#M119975</link>
      <description>&lt;P&gt;Can you explain in more detail your use case?  What you describe could be an example of &lt;CODE&gt;subsearch&lt;/CODE&gt; or &lt;CODE&gt;map&lt;/CODE&gt; (or something else), but we need more information.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 19:59:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-a-result-and-then-a-field-value-create-array-and-pass-1/m-p/416951#M119975</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-07-29T19:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: search a result and then a field value create array and pass 1 by 1 in another search query at same time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-a-result-and-then-a-field-value-create-array-and-pass-1/m-p/416952#M119976</link>
      <description>&lt;P&gt;IIt sounds like &lt;STRONG&gt;&lt;EM&gt;map&lt;/EM&gt;&lt;/STRONG&gt; is the command you are looking for:  &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Map"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Map&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;It sounds like you would like to do something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sales | stats sum(sales) as sales by product_id | map search="search index=product_details id=$product_id$" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Each product_id returned by the search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=sales | stats sum(sales) as sales by product_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Will be run through the search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=product_details id=$product_id$
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jul 2019 20:49:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-a-result-and-then-a-field-value-create-array-and-pass-1/m-p/416952#M119976</guid>
      <dc:creator>solarboyz1</dc:creator>
      <dc:date>2019-07-29T20:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: search a result and then a field value create array and pass 1 by 1 in another search query at same time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-a-result-and-then-a-field-value-create-array-and-pass-1/m-p/416953#M119977</link>
      <description>&lt;P&gt;And if adding to above I need that from the array list if something not present from the list how to achieve that&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 21:08:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-a-result-and-then-a-field-value-create-array-and-pass-1/m-p/416953#M119977</guid>
      <dc:creator>varunawasthi9</dc:creator>
      <dc:date>2019-07-29T21:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: search a result and then a field value create array and pass 1 by 1 in another search query at same time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-a-result-and-then-a-field-value-create-array-and-pass-1/m-p/416954#M119978</link>
      <description>&lt;P&gt;You would need to start with a search that returns all possible values and join that to your search. In our environment, this is generally a lookup. Here's an example that you can try in your environment.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=10
| eval product_id=random()%10+1
| join type=left max=0 product_id [
    | makeresults count=10
    | eval product_id=random()%5+1
    | stats count by product_id ]
| fillnull
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/84762"&gt;@solarboyz1&lt;/a&gt; 's example, it would look something like the command below where the "product_ids" lookup has a column called "product_id".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup product_ids
| join type=left max=0 product_id [
    | search index=sales
    | stats sum(sales) as sales by product_id
    | map search="search index=product_details id=$product_id$" ]
| fillnull
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:31:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-a-result-and-then-a-field-value-create-array-and-pass-1/m-p/416954#M119978</guid>
      <dc:creator>jacobpevans</dc:creator>
      <dc:date>2020-09-30T01:31:47Z</dc:date>
    </item>
  </channel>
</rss>

