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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...