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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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