Skip to main content
Version: 5.2

search

Description

Performs a search on the data.

danger

Using search in a query is allowed only if it is preceded by commands that also operate with the internal storage mechanisms. These include source and peval. This condition must also be met for all subqueries within the query.

Syntax

search <mode> <compare>

Required Arguments

ParameterSyntaxDescription
compare<field> > | >= | == | < | <= | != <field> | <value>A conditional operation for data comparison.

Optional Arguments

ParameterSyntaxDefaultDescription
mode(|regex|wildcard|cidr)Search mode: regex - search by regular expression; wildcard - search using wildcard characters * and ?; cidr - search by subnet mask.

Search Modes

  • regex - search using a regular expression
  • wildcard - search using wildcard characters * and ?
  • cidr - search using a subnet mask
  • text - text field search (used when enabled Configuring Keyword Autocompletion)
tip

If there is no operator between conditions, the default operator is AND.

A value (<value>) can be specified without double quotes if it does not contain separators or special characters.

Search in

SyntaxDescription
<field> in (<value>, <value>)The search in construct allows searching for events where the field <field> value equals one of the specified <value> elements.
tip

You can use * in <value> elements for wildcard search.

Query Examples

Example 1

In this example, a search will be performed for documents where the user field contains the value Smith or a value starting with Mar.

Example #1
...
| search user=Smith OR user="Mar*"

Sample input documents:

user
Smith
Maria
Taylor
John
mary

The query execution result may be the following table:

user
Smith
Maria
mary

Example 2

In this example, a search will be performed for documents where the value of the count_result field equals 5, the value of the nick field starts with Sm, and the value of the mail field starts with sm*.

Example #2
...
| search count_result=5 AND nick="Sm*" mail="sm*"

Sample input documents:

nickmailcount_result
Smithsmith@example.com5
Smhsmh123@example.com4
smit123smit@example.com5

The query execution result may be the following table:

nickmailcount_result
Smithsmith@example.com5

Example 3

In this example, a search will be performed for documents where the score field is greater than or equal to 5, and the status field is not equal to active.

Example #3
...
| search score>=5 AND NOT status="active"

Sample input documents:

userstatusscore
Smithactive5
Mariainactive4
Johninactive11

The query execution result may be the following table:

nickmailcount_result
Johninactive11

Example 4

In this example, a search will be performed for documents where the place field matches Hotel or Motel using the regex regular expression.

Example #4
...
| search regex place.keyword="(Ho|Mo)tel"

Sample input documents:

place
Hotel
motel

The query execution result may be the following table:

place
Hotel

Example 5

In this example, a search will be performed for documents where the name field starts with An, followed by li and exactly one any character.

Example #5
...
| search wildcard name="An*li?"

Sample input documents:

user
Anna
Anatoly
Anzli
Annalisa
Anli

The query execution result may be the following table:

user
Anzli
Annalisa
Anli

Example 6

In this example, a search will be performed for documents where the IPv4 address in the host field belongs to the 10.78.0.0/16 subnet.

Example #6
...
| search cidr host="10.78.0.0/16"

Sample input documents:

host
10.78.1.23
192.168.1.1
2001:0db8::1

The query execution result may be the following table:

host
10.78.1.23

Example 7

In this example, a search will be performed for documents where the IPv6 address in the host field belongs to the 2001::/4 subnet.

Example №7
...
| search cidr host="2001::/4"

Sample input documents:

host
2001:0db8::1
fe80::1
3000::1
2002:aabb::1234

The query execution result may be the following table:

host
2001:0db8::1
2002:aabb::1234

Example 8

In this example, a search will be performed for documents where the value of the user field equals Smith or starts with Mar.

Example №8
...
| search user in (Smith, "Mar*")

Sample input documents:

| | user | | -| | Smith | | Maria | | Taylor | | Jeck | | John | | mary |

The query execution result may be the following table:

user
Smith
Maria
mary