<?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 search to find a match in lookup file? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299690#M90291</link>
    <description>&lt;P&gt;That search looks a little convoluted for what you're trying to do.  Instead of using a map search, just try using a second lookup:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup file1.csv  
|search blah 
|fields "Employee Name" "Employee Number"  
|rename "Employee Number" as EmpNum  
|lookup file2.csv EmpNum OUTPUT email
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should work more efficiently.&lt;/P&gt;</description>
    <pubDate>Tue, 20 Feb 2018 12:55:31 GMT</pubDate>
    <dc:creator>sheamus69</dc:creator>
    <dc:date>2018-02-20T12:55:31Z</dc:date>
    <item>
      <title>How to search to find a match in lookup file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299689#M90290</link>
      <description>&lt;P&gt;I have 2 lookup files.&lt;BR /&gt;
Am getting empnumber from one file and then trying to search for the corresponding email id from another lookup file. &lt;BR /&gt;
Its working fine for until first non-matching empnumber. Once it's not able to find a match it stops there and is not getting further matches. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup file1.csv | search bla bla |fields "Employee Name" "Employee Number" |rename "Employee Number" as EmpNum | map[inputlookup file2.csv |search "Employee ID"=$EmpNum$ |eval email=$Employee Email$]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is working well for first 9 employees then when the 10th one doesnt find a match it stops there even though there is a match on further lines. &lt;/P&gt;

&lt;P&gt;Please help.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 12:45:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299689#M90290</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2018-02-20T12:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to search to find a match in lookup file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299690#M90291</link>
      <description>&lt;P&gt;That search looks a little convoluted for what you're trying to do.  Instead of using a map search, just try using a second lookup:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup file1.csv  
|search blah 
|fields "Employee Name" "Employee Number"  
|rename "Employee Number" as EmpNum  
|lookup file2.csv EmpNum OUTPUT email
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should work more efficiently.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 12:55:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299690#M90291</guid>
      <dc:creator>sheamus69</dc:creator>
      <dc:date>2018-02-20T12:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to search to find a match in lookup file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299691#M90292</link>
      <description>&lt;P&gt;Hi @sheamus69 &lt;/P&gt;

&lt;P&gt;Its giving me all the results from 1st lookup file not getting me the match emails&lt;BR /&gt;
And more over the column name is "Employee ID" in second lookup file and i have to search for the empnum got in 1 file to get the match first &lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 13:10:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299691#M90292</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2018-02-20T13:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to search to find a match in lookup file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299692#M90293</link>
      <description>&lt;P&gt;I'm going to revise what @sheamus69 proposed and also explain why your &lt;CODE&gt;map&lt;/CODE&gt; command is failing.&lt;/P&gt;

&lt;P&gt;First, a revised version of the search that doesn't use map:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup file1.csv  
| search blah 
| fields "Employee Name" "Employee Number"  
| rename "Employee Number" as EmpNum  
| lookup file2.csv "Employee ID" AS EmpNum OUTPUT email
| where isnotnull(email)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If there are other fields in file2.csv that you want to display, you can add them to the end of the line starting with &lt;CODE&gt;| lookup&lt;/CODE&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| lookup file2.csv "Employee ID" AS EmpNum OUTPUT email, field2, field3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The reason @sheamus69's search is returning everything (and not just the items with matches in file2.csv) is because there was no filter at the end of the search to retain only the events with matches. That's what the &lt;CODE&gt;| where isnotnull(email)&lt;/CODE&gt; part of my answer solves.&lt;/P&gt;

&lt;P&gt;In general, using &lt;CODE&gt;map&lt;/CODE&gt; should be an option of last resort, because Splunk spins up a whole new search for each mapped subsearch, using an incredible amount of resources. And nearly every time you want to use &lt;CODE&gt;map&lt;/CODE&gt;, there will be a more efficient way to structure your search that doesn't use it. But if you do use it, you should be aware of the &lt;CODE&gt;maxsearches&lt;/CODE&gt; attribute. If you don't specify a value for maxsearches, the default is 10 - which is exactly what you were hitting. Your search wasn't stopping because it didn't find a match for the 10th entry; it was stopping because you didn't specify an alternate value for &lt;CODE&gt;maxsearches&lt;/CODE&gt;. &lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 14:15:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299692#M90293</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-02-20T14:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to search to find a match in lookup file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299693#M90294</link>
      <description>&lt;P&gt;Perfect Thanks @elliotpreoebstel&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 14:24:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299693#M90294</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2018-02-20T14:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to search to find a match in lookup file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299694#M90295</link>
      <description>&lt;P&gt;My answer was typed quite quickly, so I forgot about bunging in a filter.&lt;/P&gt;

&lt;P&gt;This is a much better way of explaining it.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 15:10:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-to-find-a-match-in-lookup-file/m-p/299694#M90295</guid>
      <dc:creator>sheamus69</dc:creator>
      <dc:date>2018-02-20T15:10:03Z</dc:date>
    </item>
  </channel>
</rss>

