search
Table of Contents
Operator
search — select values based on a search expression
Synopsis
[search] <sexpr>
Description
The search
operator filters its input by applying a search expression <sexpr>
to each input value and dropping each value for which the expression evaluates
to false
or to an error.
The search
keyword is optional since it is an
implied operator.
When Zed queries are run interactively, it is convenient to be able to omit the “search” keyword, but when search filters appear in Zed source files, it is good practice to include the optional keyword.
Examples
A simple keyword search for “world”
search world
"hello,
world"
"say
hello"
"goodbye,
world"
Loading...
Search can utilize arithmetic comparisons
search this >= 2
1
2
3
Loading...
The “search” keyword may be dropped
? 2 or 3
1
2
3
Loading...
A search with Boolean logic
search this >= 2 AND this <= 2
1
2
3
Loading...
The AND operator may be omitted through predicate concatenation
search this >= 2 this <= 2
1
2
3
Loading...
Concatenation for keyword search
? foo bar
"foo"
"foo
bar"
"foo
bar
baz"
"baz"
Loading...
Search expressions match fields names too
? foo
{foo:1}
{bar:2}
{foo:3}
Loading...
Boolean functions may be called
search is(<int64>)
1
"foo"
10.0.0.1
Loading...
Boolean functions with Boolean logic
search is(<int64>) or is(<ip>)
1
"foo"
10.0.0.1
Loading...