Splunk Search

How to exclude matching results from Lookup?

mistydennis
Communicator

Hi all - I am trying to exclude matching results from a lookup and can't get it to work. I've tried multiple searches, tried what I've found in Splunk Answers, and I just can't get this to work.

Here's what I have right now:

 

| inputlookup myinputlookup1 
| search NOT 
    [ |lookup my_lookup InLookField AS LookField OUTPUT InLookField]

 


This search runs but produces no results. What am I doing wrong? 

Labels (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

If you are using a lookup as a subsearch then you use "inputlookup" rather than lookup. There are three ways to solve your problem, two with subsearches

1. Search after lookup with a subsearch

| inputlookup myinputlookup1 
| search NOT 
    [ | inputlookup my_lookup 
      | fields my_lookup_field_matching_outer_field ]

or

2. Basic Lookup 

| inputlookup myinputlookup1 
| lookup my_lookup InLookField AS LookField OUTPUT InLookField
| where isnull(InLookField)

 or

3. inputlookup with where clause using a subsearch 

| inputlookup myinputlookup1 where NOT
    [ | inputlookup my_lookup 
      | fields my_lookup_field_matching_outer_field ]

 In each subsearch case, you need to make sure that the fields returned by the subsearch are the same as the field you want to filter from the inputlookup

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

If you are using a lookup as a subsearch then you use "inputlookup" rather than lookup. There are three ways to solve your problem, two with subsearches

1. Search after lookup with a subsearch

| inputlookup myinputlookup1 
| search NOT 
    [ | inputlookup my_lookup 
      | fields my_lookup_field_matching_outer_field ]

or

2. Basic Lookup 

| inputlookup myinputlookup1 
| lookup my_lookup InLookField AS LookField OUTPUT InLookField
| where isnull(InLookField)

 or

3. inputlookup with where clause using a subsearch 

| inputlookup myinputlookup1 where NOT
    [ | inputlookup my_lookup 
      | fields my_lookup_field_matching_outer_field ]

 In each subsearch case, you need to make sure that the fields returned by the subsearch are the same as the field you want to filter from the inputlookup

Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...