Splunk Search

How to use a wildcard with a where clause?

allladin101
Explorer

Hi - I wish to use a wildcard in the where clause in the below query can someone help?

index=whatever* sourcetype=server
|rex field=CLIENT_VERSION "\'(?P.+)\'" 
|table version
|where version=*10_2*

here the value in the version field is FS_10_2_17387/FS_10_2_12387/FS_10_2_17987

Tags (4)
1 Solution

MuS
Legend

Hi alladin101,

it's me again 🙂

Now I get it; no this is not the way you use where. If you use where you will compare two fields and their respective values. You would have to use search because this will search using the value of the field.

like this:

index=whatever* sourcetype=server
 |rex field=CLIENT_VERSION "\'(?P.+)\'" 
 |table version
 |search version=*10_2*

hope this helps...

cheers, MuS

View solution in original post

MuS
Legend

Hi alladin101,

it's me again 🙂

Now I get it; no this is not the way you use where. If you use where you will compare two fields and their respective values. You would have to use search because this will search using the value of the field.

like this:

index=whatever* sourcetype=server
 |rex field=CLIENT_VERSION "\'(?P.+)\'" 
 |table version
 |search version=*10_2*

hope this helps...

cheers, MuS

MoniM
Communicator

hi,
if i want to add multiple values in the version field, can i use "AND" operator in search command?
for eg: | search version= 10 AND 12 AND 13
or how to include all three values in version field?

0 Karma

MuS
Legend

How about this?
.... | search version="10" version="12" version="13"

0 Karma

markbarber21
Path Finder

FYI - the optimizer will combine this into search(index=whatever* sourcetype=server version=*10_2*), as if it was part of the original search query.

0 Karma

MuS
Legend

Yes, this is the difference between using where and search ; search can be basically used in the base/original search where as where will compare/eval values of fields ... even back in 2014 😉

cheers, MuS

0 Karma

LAcioffi
Explorer

This just saved my life! Thanks!

0 Karma

allladin101
Explorer

Hi Mus,

Thanks for the answer 🙂

can i use this as well?
|where like(version,"%FX_10_2%")

MuS
Legend

yes, this should work as well

Get Updates on the Splunk Community!

Developer Spotlight with Brett Adams

In our third Spotlight feature, we're excited to shine a light on Brett—a Splunk consultant, innovative ...

Index This | What can you do to make 55,555 equal 500?

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

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...