spl1 command: Examples

The following are examples for using the SPL2 spl1 command. To learn more about the spl1 command, see How the SPL2 spl1 command works.

1. Searches that use the implied search command

In the SPL, the search command is implied at the beginning of some searches, such as searches that start with a keyword or a field-value pair. In SPL2 the search command must be explicitly specified.

Unless your SPL search begins with a generating command like inputlookup, makeresults, mstats, or tstats, you must include the search command when you use the spl1 command.

Here's an example:

Version Example
SPL search
index=sample_data_index action=purchase 

This SPL search starts with the implied search command and is comprised of two field-value pairs.

SPL2 search
$example1= | `search index=sample_data_index action=purchase`

In this SPL2 search, the search command is explicitly added to the SPL search and the search uses the backtick ( ` ) character syntax.

SPL2 search
$example2 = | spl1 "search index=main action=purchase"

In this SPL2 search, the search command is explicitly added to the SPL search and the search uses the explicit spl1 command syntax.

2. Using the spl1 command with only the unsupported portion of the SPL search

3. When to include the index in your search

4. Searches that contain quotation marks

When your SPL search contains quotation marks, it is easier to use the spl1 command backtick ( ` ) character syntax. When you use the explicit spl1 command syntax, you must escape the quotation marks.

The following example shows the difference between the backtick ( ` ) character syntax and the explicit spl1 command syntax:

Version Example
SPL search
|status=200 action=purchase | stats count AS "Total Purchased"
SPL2 search
$quotes1 = from sample_data_index
| `search status=200 action=purchase 
| stats count AS "Total Purchased" `

In this SPL2 search, the search uses the backtick ( ` ) character syntax.

SPL2 search
$quotes2 = from sample_data_index
| spl1 "search status=200 action=purchase 
| stats count AS \"Total Purchased\" " 

In this SPL2 search, you must escape the quotation marks because the explicit spl1 command syntax is used.