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!

Splunk Observability Cloud’s AI Assistant in Action Series: Analyzing and ...

This is the second post in our Splunk Observability Cloud’s AI Assistant in Action series, in which we look at ...

Elevate Your Organization with Splunk’s Next Platform Evolution

 Thursday, July 10, 2025  |  11AM PDT / 2PM EDT Whether you're managing complex deployments or looking to ...

Splunk Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...