Skip to main content
Version: 5.1

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.

info

By default, regular expression regex search is case-insensitive. To add case sensitivity when searching by regular expression, you must use the sens parameter in the search query.

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 Ivanov or a value starting with Mar.

Example №1
...
| search user=Ivanov OR user="Mar*"

Sample input documents:

user
Ivanov
Maria
Petrov
John
mary

The query execution result may be the following table:

user
Ivanov
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 Iv, and the value of the mail field starts with iv*.

Example №2
...
| search count_result=5 AND nick="Iv*" mail="iv*"

Sample input documents:

nickmailcount_result
Ivanovivanov@example.com5
Ivyivy123@example.com4
ivan123ivan@example.com5

The query execution result may be the following table:

nickmailcount_result
Ivanovivanov@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
Ivanovactive5
Mariainactive4
Annainactive11

The query execution result may be the following table:

nickmailcount_result
Annainactive11

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 Ivanov or starts with Mar.

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

Sample input documents:

| | user | | -| | Ivanov | | Maria | | Petrov | | Ivanova | | John | | mary |

The query execution result may be the following table:

user
Ivanov
Maria
mary