Splunk Enterprise Security

LIKE and like()

ak1508
Explorer

Just want to clear this up so I am not mistaken. Are the two statements equivalent:

 | where like (foo, "bar")

and

| where foo LIKE "bar"

In my test setup I am getting the same search results, I'm wondering if there is anything different on the backend that Splunk does. From the Job inspector it seems they both run the same Optimized search of the first option. Should this be the preferred syntax?

Thanks

niketn
Legend

@ak1508 as per color coding for SPL post Splunk 6.5, the like in the command | where foo like "bar" is an argument as it highlights as orange, but using | where like(foo,"bar") treats it as function and highlights as pink. Refer to Splunk Documentation for the same: https://docs.splunk.com/Documentation/Splunk/latest/Search/Parsingsearches#Color_codes

You should be using the second one because internally Splunk's Query Optimization converts the same to function like().

Which implies following query in Splunk Search

| makeresults
| eval data="testabc"
| where data like "test%"

Converts to the following optimized query when it executes (you can check Job Inspector for details:

 | makeresults 
 | eval data="testabc" 
 | where like(data,"test%")
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

jawaharas
Motivator

As per Splunk Docs, below syntax seems preferred.

 .. | where like (foo, "bar")
0 Karma
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.


Introducing Unified TDIR with the New Enterprise Security 8.2

Read the blog
Get Updates on the Splunk Community!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...