<?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: Error while joining two lookups based on condition in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Error-while-joining-two-lookups-based-on-condition/m-p/491430#M137189</link>
    <description>&lt;P&gt;A couple of thoughts:&lt;/P&gt;

&lt;P&gt;Your first command is an &lt;CODE&gt;|inputlookup&lt;/CODE&gt; within the subsearch, so you don't need the &lt;CODE&gt;search&lt;/CODE&gt; call. Removing it removed the error for me.&lt;/P&gt;

&lt;P&gt;You can simplify your case statement to be a simple &lt;CODE&gt;if&lt;/CODE&gt; clause, since if hostname is not null, you're taking hostname, else you're taking modelname, at least currently. You should also add a catch all if neither are populated.&lt;/P&gt;

&lt;P&gt;You can update a lookup's definition by going to settings -&amp;gt; lookups -&amp;gt; lookup definitions -&amp;gt; click the lookup -&amp;gt; advanced options -&amp;gt; Match type -&amp;gt; &lt;CODE&gt;WILDCARD(name)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I think this should work, but if you can avoid the join you should try to, since they aren't very performant:&lt;/P&gt;

&lt;P&gt;{code}&lt;BR /&gt;
| inputlookup Lookup_A where status=Live &lt;BR /&gt;
  | join type=left name &lt;BR /&gt;
     [| inputlookup Lookup_B &lt;BR /&gt;
     | eval name = case(isnotnull(hostname), hostname, isnotnull(ModelName), ModelName, 1==1, "Neither Model nor host names are &lt;BR /&gt;
      provided - this case was not previously addressed")&lt;BR /&gt;
        ]&lt;BR /&gt;
{code}&lt;/P&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 03:01:18 GMT</pubDate>
    <dc:creator>aberkow</dc:creator>
    <dc:date>2020-09-30T03:01:18Z</dc:date>
    <item>
      <title>Error while joining two lookups based on condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-while-joining-two-lookups-based-on-condition/m-p/491429#M137188</link>
      <description>&lt;P&gt;Hi ,&lt;BR /&gt;
I want to join the two lookups based on one field that I am creating conditionally in the second lookup. &lt;BR /&gt;
So, Lookup_A has "name" &lt;BR /&gt;
In Lookup_B, I need to created "name" based on condition which is listed in the eval statement below. But when I run this, I get error around Search Statement.&lt;BR /&gt;
(Error in 'search' command: Unable to parse the search: Comparator '=' is missing a term on the left hand side.) &lt;/P&gt;

&lt;P&gt;Also, is there a way to do the wildcard match on the name field ? &lt;/P&gt;

&lt;P&gt;Thanks ! &lt;/P&gt;

&lt;P&gt;|inputlookup Lookup_A where status=Live &lt;BR /&gt;
|join type=left name [search= [|inputlookup Lookup_B|eval name = case&lt;BR /&gt;
(&lt;BR /&gt;
(   (isnull(ModelName)) AND (isnotnull(hostname))   ),hostname,&lt;BR /&gt;
(   (isnull(hostname)) AND (isnotnull(ModelName))   ),ModelName,&lt;BR /&gt;
(   (isnotnull(hostname)) AND (isnotnull(ModelName))   ),hostname&lt;BR /&gt;
)&lt;BR /&gt;
]]&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:06:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-while-joining-two-lookups-based-on-condition/m-p/491429#M137188</guid>
      <dc:creator>rohankin</dc:creator>
      <dc:date>2020-09-30T03:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Error while joining two lookups based on condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-while-joining-two-lookups-based-on-condition/m-p/491430#M137189</link>
      <description>&lt;P&gt;A couple of thoughts:&lt;/P&gt;

&lt;P&gt;Your first command is an &lt;CODE&gt;|inputlookup&lt;/CODE&gt; within the subsearch, so you don't need the &lt;CODE&gt;search&lt;/CODE&gt; call. Removing it removed the error for me.&lt;/P&gt;

&lt;P&gt;You can simplify your case statement to be a simple &lt;CODE&gt;if&lt;/CODE&gt; clause, since if hostname is not null, you're taking hostname, else you're taking modelname, at least currently. You should also add a catch all if neither are populated.&lt;/P&gt;

&lt;P&gt;You can update a lookup's definition by going to settings -&amp;gt; lookups -&amp;gt; lookup definitions -&amp;gt; click the lookup -&amp;gt; advanced options -&amp;gt; Match type -&amp;gt; &lt;CODE&gt;WILDCARD(name)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I think this should work, but if you can avoid the join you should try to, since they aren't very performant:&lt;/P&gt;

&lt;P&gt;{code}&lt;BR /&gt;
| inputlookup Lookup_A where status=Live &lt;BR /&gt;
  | join type=left name &lt;BR /&gt;
     [| inputlookup Lookup_B &lt;BR /&gt;
     | eval name = case(isnotnull(hostname), hostname, isnotnull(ModelName), ModelName, 1==1, "Neither Model nor host names are &lt;BR /&gt;
      provided - this case was not previously addressed")&lt;BR /&gt;
        ]&lt;BR /&gt;
{code}&lt;/P&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:01:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-while-joining-two-lookups-based-on-condition/m-p/491430#M137189</guid>
      <dc:creator>aberkow</dc:creator>
      <dc:date>2020-09-30T03:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: Error while joining two lookups based on condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-while-joining-two-lookups-based-on-condition/m-p/491431#M137190</link>
      <description>&lt;P&gt;You don't need two subsearches.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup Lookup_A where status=Live
|join type=left name [|inputlookup Lookup_B|eval name = case
(
( (isnull(ModelName)) AND (isnotnull(hostname)) ),hostname,
( (isnull(hostname)) AND (isnotnull(ModelName)) ),ModelName,
( (isnotnull(hostname)) AND (isnotnull(ModelName)) ),hostname
)
]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You also don't need &lt;CODE&gt;join&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup Lookup_B|eval name = case
(
( (isnull(ModelName)) AND (isnotnull(hostname)) ),hostname,
( (isnull(hostname)) AND (isnotnull(ModelName)) ),ModelName,
( (isnotnull(hostname)) AND (isnotnull(ModelName)) ),hostname
)
|inputlookup append=true Lookup_A where status=Live
| stats values(*) as * by name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2019 20:45:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-while-joining-two-lookups-based-on-condition/m-p/491431#M137190</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-11-19T20:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: Error while joining two lookups based on condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-while-joining-two-lookups-based-on-condition/m-p/491432#M137191</link>
      <description>&lt;P&gt;Hi @rohankin,&lt;BR /&gt;
did you tried something like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup Lookup_B
|eval name = case(
     ( (isnull(ModelName)) AND (isnotnull(hostname)) ),hostname,
     ( (isnull(hostname)) AND (isnotnull(ModelName)) ),ModelName,
     ( (isnotnull(hostname)) AND (isnotnull(ModelName)) ),hostname
     )
| lookup lookup_A name OUTPUT status &amp;lt;and other fields if needed&amp;gt;
| search status=Live
| table name &amp;lt;other fields&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 08:29:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-while-joining-two-lookups-based-on-condition/m-p/491432#M137191</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-11-20T08:29:03Z</dc:date>
    </item>
  </channel>
</rss>

