I am trying to search source=test.csv (including fieldA) with the attached lookup file.
I define the automatic lookup like 'URL as fieldA OUTPUTNEW DomainGroup AS Domain4fieldA'.
Then I search like 'source=test.csv (Domain4fieldA="G1" OR Domain4fieldA="G2") | eval Service=Domain4fieldA | fields fieldA,Service'
How can I search to get the correct result ?
I understand your thinking, but here is what really happens
First, Splunk identifies all the events in the index that match your criteria. These events have various fieldA values. Let's pretend that the first two events look like this:
fieldA=www.google.co.jp fieldB=other_data a message here fieldA=www.splunk.com fieldB=something_else a different message here
Second, Splunk performs the lookup (it can't complete the search until it gets the values for
Domain4fieldA). When Splunk does the lookup, it finds ALL of the matching values and adds them to the events as a multi-valued field. This effectively does this:
fieldA=www.google.co.jp fieldB=other_data a message here Domain4fieldA=G1,G2,G3 fieldA=www.splunk.com fieldB=something_else a different message here Domain4fieldA=G2,G4
Third, Splunk determines which events now match your criteria - they have a value of either G1 or G2 in the Domain4fieldA. Both events qualify. Note that this does NOT eliminate the non-matching values of
Domain4fieldA. It only eliminates events that don't have a matching value for
table commands are processed as usual.
If you don't want to see the other values in the multi-valued field, you will need to remove them. Try this command:
source=test.csv (Domain4fieldA="G1" OR Domain4fieldA="G2") | eval Service==mvfilter(match(Domain4fieldA, "G1") OR match(Domain4fieldA, "G2")) | fields fieldA,Service