<?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 of Lookup with search query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Use-of-Lookup-with-search-query/m-p/427338#M122340</link>
    <description>&lt;P&gt;One way to do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval holdings="U14355|U114576|D105994"
| makemv delim="|" holdings
| mvexpand holdings
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This breaks up your holdings field into 3 separate events that can be compared against the field in your lookup.&lt;/P&gt;

&lt;P&gt;In your case, it would look something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test sourcetype="test_logs" "Customer Cart:"
| rex field=_raw "holdings \= \'{(?[^}]+)}\'" 
| makemv delim="|" holdings
| mvexpand holdings
| lookup codes.csv (column) AS holdings
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Where (column) is the column in your CSV that has the code you're looking for.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Aug 2019 12:17:36 GMT</pubDate>
    <dc:creator>jpolvino</dc:creator>
    <dc:date>2019-08-05T12:17:36Z</dc:date>
    <item>
      <title>Use of Lookup with search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-of-Lookup-with-search-query/m-p/427337#M122339</link>
      <description>&lt;P&gt;Hi, I need some help related to a search query. My search query has a field called "holdings" which contain data like this - &lt;BR /&gt;
"U14355|U114576|D105994". And i have a lookup with 600 unique codes like D123456, D876845 etc. (All starts with D)&lt;BR /&gt;
Now I want to search only those events where one of the holdings also present in the lookup values.&lt;BR /&gt;
For example - event with holdings as "U14355|U114576|D105994" should only return if D105994 is also present in the lookup.&lt;BR /&gt;
Any help is much appreciated. Below query is obviously wrong -&lt;/P&gt;

&lt;P&gt;index=test sourcetype="test_logs" "Customer Cart:"&lt;BR /&gt;
| rex field=_raw "holdings = \'{(?[^}]+)}\'" &lt;BR /&gt;
| join holdings [| inputlookup codes.csv]&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:36:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-of-Lookup-with-search-query/m-p/427337#M122339</guid>
      <dc:creator>Shashank_87</dc:creator>
      <dc:date>2020-09-30T01:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Use of Lookup with search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-of-Lookup-with-search-query/m-p/427338#M122340</link>
      <description>&lt;P&gt;One way to do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval holdings="U14355|U114576|D105994"
| makemv delim="|" holdings
| mvexpand holdings
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This breaks up your holdings field into 3 separate events that can be compared against the field in your lookup.&lt;/P&gt;

&lt;P&gt;In your case, it would look something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test sourcetype="test_logs" "Customer Cart:"
| rex field=_raw "holdings \= \'{(?[^}]+)}\'" 
| makemv delim="|" holdings
| mvexpand holdings
| lookup codes.csv (column) AS holdings
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Where (column) is the column in your CSV that has the code you're looking for.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2019 12:17:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-of-Lookup-with-search-query/m-p/427338#M122340</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2019-08-05T12:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: Use of Lookup with search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-of-Lookup-with-search-query/m-p/427339#M122341</link>
      <description>&lt;P&gt;@jpolvino Thank you for your response. mvexpand increases the eventcount. What i need is only unique sessions. Can i do dedup uniqueID after this. Will it be valid?&lt;/P&gt;

&lt;P&gt;Also this lookup command has to be supplied with OUTPUT fields. what should i write there? I only have one field in the lookup.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2019 13:15:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-of-Lookup-with-search-query/m-p/427339#M122341</guid>
      <dc:creator>Shashank_87</dc:creator>
      <dc:date>2019-08-05T13:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Use of Lookup with search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-of-Lookup-with-search-query/m-p/427340#M122342</link>
      <description>&lt;P&gt;If you want to preserve the event count for your holdings field, then use a temp field like n:&lt;BR /&gt;
    index=test sourcetype="test_logs" "Customer Cart:"&lt;BR /&gt;
    | rex field=_raw "holdings = \'{(?[^}]+)}\'" &lt;BR /&gt;
    | eval n=split(holdings,"|")&lt;BR /&gt;
    | mvexpand n&lt;BR /&gt;
    | lookup codes.csv (column) AS n OUTPUT (field you want to see)&lt;BR /&gt;
At the end just list the field you want to see as output.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:36:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-of-Lookup-with-search-query/m-p/427340#M122342</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2020-09-30T01:36:06Z</dc:date>
    </item>
  </channel>
</rss>

