<?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: return a list from subsearch and use it in main search. return not properly formatted in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/return-a-list-from-subsearch-and-use-it-in-main-search-return/m-p/676770#M231441</link>
    <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;IN&lt;/FONT&gt; operator maps to a series of &lt;FONT face="courier new,courier"&gt;OR&lt;/FONT&gt; operators (check the Job Inspector) so forcing a set of &lt;FONT face="courier new,courier"&gt;OR&lt;/FONT&gt; operators into &lt;FONT face="courier new,courier"&gt;IN&lt;/FONT&gt;-compatible form is a wasted effort.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Feb 2024 17:39:02 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2024-02-06T17:39:02Z</dc:date>
    <item>
      <title>return a list from subsearch and use it in main search. return not properly formatted</title>
      <link>https://community.splunk.com/t5/Splunk-Search/return-a-list-from-subsearch-and-use-it-in-main-search-return/m-p/676769#M231440</link>
      <description>&lt;P&gt;i have a splunk query below that returns me&amp;nbsp;&lt;/P&gt;&lt;P&gt;( ( ( list_value2="dev1" OR list_value2="dev2" OR list_value2="dev5" OR list_value2="dev6" ) ) )&lt;BR /&gt;&lt;BR /&gt;i want to use this 4 values as a list to query using IN operation from another main search as show in the second code snippet.&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;index=main label=y userid=tom&lt;BR /&gt;| fields associateddev&lt;BR /&gt;| eval list_value = replace(associateddev,"{'","")&lt;BR /&gt;| eval list_value = replace(list_value,"'}","")&lt;BR /&gt;| eval list_value = split(list_value,"', '")&lt;BR /&gt;| mvexpand list_value&lt;BR /&gt;| stats values(list_value) as list_value2&lt;BR /&gt;| format&lt;/P&gt;&lt;P&gt;```&lt;BR /&gt;&lt;BR /&gt;i want to use the results from this as part of a subsearch to query another source as shown below. ideally, the subsearch will return me a list that i can just call using | where hname IN&amp;nbsp;list_value2. But list_value2 is returning me this&amp;nbsp;( ( ( list_value2="dev1" OR list_value2="dev2" OR list_value2="dev5" OR list_value2="dev6" ) ) ) weird string.&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;index="main" label=x&lt;BR /&gt;| where hname IN [search index=main label=y userid=tom&lt;BR /&gt;| fields associateddev&lt;BR /&gt;| eval list_value = replace(associateddev,"{'","")&lt;BR /&gt;| eval list_value = replace(list_value,"'}","")&lt;BR /&gt;| eval list_value = split(list_value,"', '")&lt;BR /&gt;| mvexpand list_value&lt;BR /&gt;| stats values(list_value) as list_value2]&lt;BR /&gt;| table _time, hname, list_value2&lt;/P&gt;&lt;P&gt;```&lt;BR /&gt;&lt;BR /&gt;i have tried&amp;nbsp;&lt;BR /&gt;| stats values(list_value) as search&lt;BR /&gt;| format mvsep="," "" "" "" "" "" ""]&lt;BR /&gt;&lt;BR /&gt;but i still get the error:&amp;nbsp;Error in 'search' command: Unable to parse the search: Right hand side of IN must be a collection of literals. '(dev1 dev2 dev5 dev6)' is not a literal.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 17:33:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/return-a-list-from-subsearch-and-use-it-in-main-search-return/m-p/676769#M231440</guid>
      <dc:creator>zebraslunker</dc:creator>
      <dc:date>2024-02-06T17:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: return a list from subsearch and use it in main search. return not properly formatted</title>
      <link>https://community.splunk.com/t5/Splunk-Search/return-a-list-from-subsearch-and-use-it-in-main-search-return/m-p/676770#M231441</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;IN&lt;/FONT&gt; operator maps to a series of &lt;FONT face="courier new,courier"&gt;OR&lt;/FONT&gt; operators (check the Job Inspector) so forcing a set of &lt;FONT face="courier new,courier"&gt;OR&lt;/FONT&gt; operators into &lt;FONT face="courier new,courier"&gt;IN&lt;/FONT&gt;-compatible form is a wasted effort.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 17:39:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/return-a-list-from-subsearch-and-use-it-in-main-search-return/m-p/676770#M231441</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-02-06T17:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: return a list from subsearch and use it in main search. return not properly formatted</title>
      <link>https://community.splunk.com/t5/Splunk-Search/return-a-list-from-subsearch-and-use-it-in-main-search-return/m-p/676773#M231444</link>
      <description>&lt;P&gt;Noted on that, but, this throws me an&amp;nbsp;Error in 'where' command: The expression is malformed. Expected ).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;index="main" label=x source="C:\\Users\\me\\Documents\\test22.csv"&lt;BR /&gt;| eval hm = replace(hostname,",","")&lt;BR /&gt;| where hm IN ([search index=main label=y userid=tom&lt;BR /&gt;| fields associateddev&lt;BR /&gt;| eval list_value = replace(associateddev,"{'","")&lt;BR /&gt;| eval list_value = replace(list_value,"'}","")&lt;BR /&gt;| eval list_value = split(list_value,"', '")&lt;BR /&gt;| mvexpand list_value&lt;BR /&gt;| stats values(list_value) as search])&lt;BR /&gt;&lt;BR /&gt;but this works assuming i dont do any operations to hostname column. is it possible to insert some eval on hostname before doing the IN operation?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;index="main" label=x source="C:\\Users\\me\\Documents\\test22.csv" hostname IN ([search index=main label=y userid=tom&lt;BR /&gt;| fields associateddev&lt;BR /&gt;| eval list_value = replace(associateddev,"{'","")&lt;BR /&gt;| eval list_value = replace(list_value,"'}","")&lt;BR /&gt;| eval list_value = split(list_value,"', '")&lt;BR /&gt;| mvexpand list_value&lt;BR /&gt;| stats values(list_value) as search])&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 18:00:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/return-a-list-from-subsearch-and-use-it-in-main-search-return/m-p/676773#M231444</guid>
      <dc:creator>zebraslunker</dc:creator>
      <dc:date>2024-02-06T18:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: return a list from subsearch and use it in main search. return not properly formatted</title>
      <link>https://community.splunk.com/t5/Splunk-Search/return-a-list-from-subsearch-and-use-it-in-main-search-return/m-p/676774#M231445</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;where&lt;/FONT&gt; command does not support the &lt;FONT face="courier new,courier"&gt;IN&lt;/FONT&gt; operator.&amp;nbsp; It does support the &lt;FONT face="courier new,courier"&gt;in&lt;/FONT&gt; function, which has a different syntax.&lt;/P&gt;&lt;P&gt;The point of my original reply to say that extra code to force a set of values into a comma-separated list for the benefit of the &lt;FONT face="courier new,courier"&gt;IN&lt;/FONT&gt; operator is wasted effort.&amp;nbsp; The interpreter is just going to convert that comma-separated list into a series of &lt;FONT face="courier new,courier"&gt;OR&lt;/FONT&gt; operators so you might well just take the raw result from the subsearch (without using&lt;FONT face="courier new,courier"&gt;IN&lt;/FONT&gt;).&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 18:13:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/return-a-list-from-subsearch-and-use-it-in-main-search-return/m-p/676774#M231445</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-02-06T18:13:04Z</dc:date>
    </item>
  </channel>
</rss>

