Show answerHide answer
Correct answer: D TERM ()
Explanation
Explanation:This question tests knowledge of specific SPL search commands and functions used for precise, literal string matching, particularly when dealing with special characters.
Let's analyze each option:
A. CASE():
Incorrect. The CASE function is used for conditional logic within an eval statement (similar to a "switch" or "if-then-else" statement in programming). It does not affect how terms are matched in the index. For example: eval severity = CASE(priority=1, "HIGH", priority=2, "MEDIUM", 1=1, "LOW").
B. LIKE():
Incorrect. The LIKE function is used for pattern matching with wildcards (% for multiple characters, _ for a single character) within a WHERE or EVAL clause. It is not used for matching a single, exact term in the index. For example: WHERE user LIKE "admin%".
C. FORMAT():
Incorrect. The FORMAT function is used to format numbers or timestamps into a specific string representation. It does not perform term matching. For example: eval formatted_time = strftime(_time, "%Y-%m-%d").
D. TERM():
Correct. The TERM() function is used specifically for this purpose. It tells Splunk's search processing to treat everything inside the parentheses as a single, literal term, ignoring any minor breakers (like periods, underscores, or hyphens) that would normally cause the term to be split into multiple parts during indexing. This is essential for searching for exact values like email addresses (TERM("user@domain.com")), hostnames with dots (TERM("server01.prod.net")), or any field value containing special characters.
Reference:
Splunk Documentation for the TERM() function. Using TERM() ensures that the search looks for the exact sequence of characters as a single unit.
Key Takeaway:
When you need to search for an exact phrase that contains characters typically treated as word separators (like ., -, _), you should wrap the phrase in the TERM() function to force Splunk to match it as a single entity.