Splunk Search

Is it possible to do faceted search with Splunk, similarly to what we do with Solr?

bemantunes
Explorer

I'm new to Splunk and I have been searching for a way to do faceted search, similarly to what I have been doing with Solr. BUt no success so far. Hope you can give me a hand on this.

Imagine I have the following data sample.

PARAMETER01 | PARAMETER02 | PARAMETER03
house | road | road
car | tree | house
road | car | car
tree | car | house

What I want to know is how many times a search matches a specific field. For instance, I want to be able to search for "house" and get the following results:

PARAMETER01: 1
PARAMETER02: 0
PARAMETER03: 2

Can I do this with Splunk?
Thank you in advance.

Tags (2)
0 Karma
1 Solution

woodcock
Esteemed Legend

You can do it as a one-off like this:

 ... | stats count(eval(PARAMETER01="house")) AS PARAMETER01 count(eval(PARAMETER02="house")) AS PARAMETER02 count(eval(PARAMETER03="house")) AS PARAMETER03

But you should probably convert this to a macro which you can call like this:

... | `MyMacro("house")`

View solution in original post

bemantunes
Explorer

Hi everyone,

I found the solution provided to be very slow, especially when we have a considerable number of fields to search.

Is there an alternative way to get the same results?
Or is there any way to optimize the Splunk dataset to improve this kind of search?

Thanks in advance.

0 Karma

woodcock
Esteemed Legend

Using stats is the most efficient (quickest) way to do this kind of thing.

0 Karma

woodcock
Esteemed Legend

You can do it as a one-off like this:

 ... | stats count(eval(PARAMETER01="house")) AS PARAMETER01 count(eval(PARAMETER02="house")) AS PARAMETER02 count(eval(PARAMETER03="house")) AS PARAMETER03

But you should probably convert this to a macro which you can call like this:

... | `MyMacro("house")`

bemantunes
Explorer

Thanks woodcock!

It worked like expected. I just changed it a little bit to be able to do a more robust search:

... | stats count(eval(searchmatch("PARAMETER01=*house*")) AS PARAMETER01 count(searchmatch("PARAMETER02=*house*")) AS PARAMETER02 count(searchmatch("PARAMETER03=*house*")) AS PARAMETER03
Get Updates on the Splunk Community!

Wrapping Up Cybersecurity Awareness Month

October might be wrapping up, but for Splunk Education, cybersecurity awareness never goes out of season. ...

🌟 From Audit Chaos to Clarity: Welcoming Audit Trail v2

🗣 You Spoke, We Listened  Audit Trail v2 wasn’t written in isolation—it was shaped by your voices.  In ...

What's New in Splunk Observability - October 2025

What’s New?    We’re excited to announce the latest enhancements to Splunk Observability Cloud and share ...