Splunk Search

Is it possible to match a string in a lookup against a keyword?

Ker_splunk
Engager

Hi Splunk Community,

 

I wondered if there was any way to match a keyword against a string in a lookup.  For example:

 

I have a lookup containing a field with a string:

 

items description
"orange apple banana"  fruit

 

I have this field in my search results:

item

"apple"

 

 

|makeresults
| eval item="apple"

 

 

Is there any way I can look-up the lookup above to match "apple" against "orange apple banana" and output "fruit" from the description field?

I can achieve the reverse of this with wildcard matching (e.g. "orange apple banana" > *apple*), but haven't been able to find a way to match against a string.

Does anyone know if this is possible?

Thanks

 

 

Labels (3)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

I did this occasionally but it can be very expensive.  Something like

 

| append
    [| inputlookup itemslookup.csv
    | eval items = split(items, " ")]
| stats values(item) as item values(items) as items values(description) as description
| mvexpand item
| eval description = if(in(item, items), description, null())

 

The output looks like

item
items
description
apple
apple
banana
orange
fruit
potato
apple
banana
orange
 

This is tested with the following emulation

 

| makeresults
| fields - _time
| eval item = mvappend("apple", "potato")
| mvexpand item
``` data emulation above ```

 

View solution in original post

Tags (2)

Ker_splunk
Engager

Good thinking! Thanks

0 Karma

yuanliu
SplunkTrust
SplunkTrust

I did this occasionally but it can be very expensive.  Something like

 

| append
    [| inputlookup itemslookup.csv
    | eval items = split(items, " ")]
| stats values(item) as item values(items) as items values(description) as description
| mvexpand item
| eval description = if(in(item, items), description, null())

 

The output looks like

item
items
description
apple
apple
banana
orange
fruit
potato
apple
banana
orange
 

This is tested with the following emulation

 

| makeresults
| fields - _time
| eval item = mvappend("apple", "potato")
| mvexpand item
``` data emulation above ```

 

Tags (2)
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!

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

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 ...