Splunk Search

Inputlookup used twice in 1 search with a NOT

willadams
Contributor

I have a problem with a 2nd NOT inputlookup that doesn't work.  If I break out of the 2nd inputlookup and run this within SPL it works.  For example the following search would work

 

 

index=foo sourcetype=foosource
[| inputlookup mystuff.csv
| rename field1 AS interest
| fields interest
]
| search NOT interest IN ("*jump*","*sheet*","*hang*","*worry*")
| table interest

 

 

 however if I then move this into a lookup it ignores the CSV file and shows  me data that I have omitted

 

 

index=foo sourcetype=foosource
[| inputlookup mystuff.csv
| rename field1 AS interest
| fields interest
]
| search NOT [|inputlookup myexcludedstuff.csv | rename field1 AS interest | fields interest]
| table interest

 

 

 

 
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try adding format to the subsearch.

index=foo sourcetype=foosource
[| inputlookup mystuff.csv
| rename field1 AS interest
| fields interest
]
| search NOT [|inputlookup mystuff.csv | rename field1 AS interest | fields interest | format]
| table interest

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

willadams
Contributor

Apologies I have corrected the 2nd XML example (copy and paste fail).  I tried to add a | format to my subsearch but it still operates as though the NOT for the lookup doesn't exist.

 

 

index=foo sourcetype=foosource
[| inputlookup mystuff.csv
| rename field1 AS interest
| fields interest
]
| search NOT [|inputlookup myexcludedstuff.csv | rename field1 AS interest | fields interest | format]
| table interest

 

 
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Where is the XML?

Another format command may be needed.

index=foo sourcetype=foosource
[| inputlookup mystuff.csv
| rename field1 AS interest
| fields interest | format
]
| search NOT [|inputlookup myexcludedstuff.csv | rename field1 AS interest | fields interest | format]
| table interest

Or you can use a single statement

index=foo sourcetype=foosource
[| inputlookup mystuff.csv
| rename field1 AS interest
| fields interest | format
] 
NOT [|inputlookup myexcludedstuff.csv | rename field1 AS interest | fields interest | format]
| table interest

The objective is to turn each lookup table into a valid expression such as (interest="foo" OR interest="bar") and the final query becomes

index=foo sourcetype=foosource (interest="foo" OR interest="bar")
NOT (interest="baz" OR interest="bat")
| table interest

You can verify what the final query looks like in the search log.

Run each inputlookup command separately to verify the results are valid expressions.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...