<?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: Use a single field in a lookup table to search across multiple fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Use-a-single-field-in-a-lookup-table-to-search-across-multiple/m-p/630002#M218863</link>
    <description>&lt;P&gt;best/most efficient will depends, however, you can do a couple of ways with SPL.&lt;/P&gt;&lt;P&gt;Assuming you have a lookup with a field called 'ip'&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search [ | inputlookup your_ip_list.csv
  ``` Pick your lookup named ip address field ```
  | fields ip 
  ``` Now for every other field name you want to assign, create a new field
      and assign it to the same IP address ```
  | eval src_ip=ip
  | format "(" "(" "OR" ")" "OR" ")"
]&lt;/LI-CODE&gt;&lt;P&gt;That will end up with this structure as the return from the subsearch&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;( ( ip="10.0.0.9" OR src_ip="10.0.0.9" ) OR ( ip="10.0.0.8" OR src_ip="10.0.0.8" ) )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Note that the first OR in the format statement will change the default AND between the same IP address to OR, allowing it to search all fields.&lt;/P&gt;&lt;P&gt;Note that if you have lots of IP addresses and lots of fields, this will end up as a huge subsearch, so may be less efficient than doing a simple lookup, i.e.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search 
| eval lookup_ip = coalesce(ip, src_ip, my_ip, xyz_ip)
| lookup your_ip_list.csv ip as lookup_ip OUTPUT ip as found&lt;/LI-CODE&gt;&lt;P&gt;This creates a single 'lookup_ip' field which is taken from one of a range of field names and then the simple lookup will return 'found' field as the ip address if it's found&lt;/P&gt;</description>
    <pubDate>Wed, 08 Feb 2023 01:10:08 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2023-02-08T01:10:08Z</dc:date>
    <item>
      <title>Use a single field in a lookup table to search across multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-a-single-field-in-a-lookup-table-to-search-across-multiple/m-p/630000#M218862</link>
      <description>&lt;P&gt;I have a simple lookup table that contains a list of IPs.&amp;nbsp; I'd like to take this list and search across all of my indexes, which don't all use the same fields for source/destination IPs.&amp;nbsp; What would be the best/most efficient way to search all of these indexes for IP matches?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 00:42:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-a-single-field-in-a-lookup-table-to-search-across-multiple/m-p/630000#M218862</guid>
      <dc:creator>splunkzilla</dc:creator>
      <dc:date>2023-02-08T00:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: Use a single field in a lookup table to search across multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-a-single-field-in-a-lookup-table-to-search-across-multiple/m-p/630002#M218863</link>
      <description>&lt;P&gt;best/most efficient will depends, however, you can do a couple of ways with SPL.&lt;/P&gt;&lt;P&gt;Assuming you have a lookup with a field called 'ip'&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search [ | inputlookup your_ip_list.csv
  ``` Pick your lookup named ip address field ```
  | fields ip 
  ``` Now for every other field name you want to assign, create a new field
      and assign it to the same IP address ```
  | eval src_ip=ip
  | format "(" "(" "OR" ")" "OR" ")"
]&lt;/LI-CODE&gt;&lt;P&gt;That will end up with this structure as the return from the subsearch&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;( ( ip="10.0.0.9" OR src_ip="10.0.0.9" ) OR ( ip="10.0.0.8" OR src_ip="10.0.0.8" ) )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Note that the first OR in the format statement will change the default AND between the same IP address to OR, allowing it to search all fields.&lt;/P&gt;&lt;P&gt;Note that if you have lots of IP addresses and lots of fields, this will end up as a huge subsearch, so may be less efficient than doing a simple lookup, i.e.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search 
| eval lookup_ip = coalesce(ip, src_ip, my_ip, xyz_ip)
| lookup your_ip_list.csv ip as lookup_ip OUTPUT ip as found&lt;/LI-CODE&gt;&lt;P&gt;This creates a single 'lookup_ip' field which is taken from one of a range of field names and then the simple lookup will return 'found' field as the ip address if it's found&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 01:10:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-a-single-field-in-a-lookup-table-to-search-across-multiple/m-p/630002#M218863</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-02-08T01:10:08Z</dc:date>
    </item>
  </channel>
</rss>

