Refine your search:

I have a defined field that I'm trying to perform searches against with wild cards, so given the texts:

  1. text2search blah blah
  2. blah text2search blah
  3. blah blah text2search

And the following searches should return the specified item:

  • my_field="*text2search" --> #3
  • my_field="*text2search*" --> #1, 2, 3
  • my_field="text2search*" --> #1

But A and C actually return nothing. How would I get this to work like I expect it?

Thanks!

asked 27 May '10, 05:44

alfredhong's gravatar image

alfredhong
11
accept rate: 0%

edited 19 Aug '10, 18:26

Stephen%20Sorkin's gravatar image

Stephen Sorkin ♦
7.1k47


5 Answers:

This should normally work, and its failure probably has something to do with the heuristic of looking for the value in the index. The first check to make is to not put the field comparison in the initial part of the search. Does a search for just *text2search yield all the results that should match your field search. Another way is instead of:

my_field="*text2search"

Try:

* | search my_field="*text2search"
link

answered 19 Aug '10, 18:39

Stephen%20Sorkin's gravatar image

Stephen Sorkin ♦
7.1k47
accept rate: 52%

How is the field my_field actually extracted? Are there actually spaces delimiting both sides of text2search (and blah) in all cases? Is text2search actually just a word without internal spaces or punctuation? Does the search work if you don't specify my_field but just search for text2search (or *text2search or whatever)? Are you running these searches from the Splunk GUI?

link

answered 27 May '10, 11:06

gkanapathy's gravatar image

gkanapathy ♦
24.1k1620
accept rate: 43%

gkanapathy raises good questions. If the below search works for case A then perhaps the field extraction may need to be tweaked to remove leading/trailing spaces or tabs.

my_field="*text2search*" | eval my_field=trim(my_field) | search my_field="*text2search"
link

answered 27 May '10, 13:21

bwooden's gravatar image

bwooden ♦
1.6k19
accept rate: 40%

Great questions. Let me clarify them:

How is the field my_field actually extracted?

It is extracted via a regex in transforms.conf, and it can be "a sentence like this". Segmentation is set to inner for the source.

Are there actually spaces delimiting both sides of text2search (and blah) in all cases?

Not in terms of my example; I meant for "text2search" to mean exactly a word.

Is text2search actually just a word without internal spaces or punctuation?

Yes.

Does the search work if you don't specify my_field but just search for text2search (or *text2search or whatever)?

Not exactly. It seems for a past 24 hour search I get the same result for *text2search, text2search, text2search*, text2search.

Are you running these searches from the Splunk GUI?

Yes, tried that to verify against programmatic searches, which have the same results

link

answered 27 May '10, 16:19

alfredhong's gravatar image

alfredhong
11
accept rate: 0%

1

Please add your clarifications to your original post (use the "edit" link) instead of adding a new "answer" like this.

(28 May '10, 15:58) Lowell ♦

To backup the answer from Stephen Sorkin, I've had a similar problem with searches using wildcards, and found it was resolved through putting the wildcard query after | search

The link between my situation and that of the original poster I think is segmentation startegy. I've come across this problem when experimenting with using outer segmentation. Are issues with wildcard searches in this way related to disabling full segmentation?

link

answered 18 Jan '11, 09:33

sumnerm's gravatar image

sumnerm
534
accept rate: 75%

Post your answer
toggle preview

Follow this question

Log In to enable email subscriptions

RSS:

Answers

Answers + Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×1,078
×327
×14

Asked: 27 May '10, 05:44

Seen: 1,597 times

Last updated: 18 Jan '11, 09:33

Copyright © 2005-2012 Splunk, Inc. All rights reserved.