Partilhar via


search operator

Applies to: ✅Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Pesquisa um padrão de texto em várias tabelas e colunas.

Note

If you know the specific tables and columns you want to search, it's more performant to use the union and where operators. O operador search pode ser lento ao pesquisar em um grande número de tabelas e colunas.

Syntax

[T|] search [kind=CaseSensitivity ] [in(TableSources)] SearchPredicate

Learn more about syntax conventions.

Parameters

Name Tipo Required Description
T string The tabular data source to be searched over, such as a table name, a union operator, or the results of a tabular query. Can't be specified together with TableSources.
CaseSensitivity string Um sinalizador que controla o comportamento de todos os operadores escalares string, como has, em relação à diferenciação de maiúsculas e minúsculas. Os valores válidos são default, case_insensitive, case_sensitive. As opções default e case_insensitive são sinônimos, já que o comportamento padrão não diferencia maiúsculas de minúsculas.
TableSources string Uma lista separada por vírgulas de nomes de tabelas "curinga" para participar da pesquisa. The list has the same syntax as the list of the union operator. Can't be specified together with tabular data source (T).
SearchPredicate string ✔️ Uma expressão booleana a ser avaliada para cada registro na entrada. Se ele retornar true, o registro será gerado. Consulte sintaxe de predicados de pesquisa.

Note

If both tabular data source (T) and TableSources are omitted, the search is carried over all unrestricted tables and views of the database in scope.

Sintaxe do predicado de pesquisa

The SearchPredicate allows you to search for specific terms in all columns of a table. O operador que é aplicado a um termo de pesquisa depende da presença e colocação de um asterisco curinga (*) no termo, conforme mostrado na tabela a seguir.

Literal Operator
billg has
*billg hassuffix
billg* hasprefix
*billg* contains
bi*lg matches regex

Você também pode restringir a pesquisa a uma coluna específica, procurar uma correspondência exata em vez de uma correspondência de termo ou pesquisar por expressão regular. A sintaxe para cada um desses casos é mostrada na tabela a seguir.

Syntax Explanation
ColumnName:StringLiteral Essa sintaxe pode ser usada para restringir a pesquisa a uma coluna específica. O comportamento padrão é pesquisar todas as colunas.
ColumnName==StringLiteral Essa sintaxe pode ser usada para pesquisar correspondências exatas de uma coluna em relação a um valor de cadeia de caracteres. O comportamento padrão é procurar uma correspondência de termos.
Columnmatches regexStringLiteral This syntax indicates regular expression matching, in which StringLiteral is the regex pattern.

Use expressões booleanas para combinar condições e criar pesquisas mais complexas. Por exemplo, "error" and x==123 resultaria em uma pesquisa por registros que têm o termo error em qualquer coluna e o valor 123 na coluna x.

Exemplos de sintaxe de predicados de pesquisa

# Syntax Significado (equivalente where) Comments
1 search "err" where * has "err"
2 search in (T1,T2,A*) "err" união T1,T2,A* | onde * tem "errar"
3 search col:"err" where col has "err"
4 search col=="err" where col=="err"
5 search "err*" where * hasprefix "err"
6 search "*err" where * hassuffix "err"
7 search "*err*" where * contains "err"
8 search "Lab*PC" where * matches regex @"\bLab.*PC\b"
9 search * where 0==0
10 search col matches regex "..." where col matches regex "..."
11 search kind=case_sensitive Todas as comparações de cadeia de caracteres diferenciam maiúsculas de minúsculas
12 search "abc" and ("def" or "hij") where * has "abc" and (* has "def" or * has hij")
13 search "err" or (A>a and A<b) where * has "err" or (A>a and A<b)

Remarks

Unlike the find operator, the search operator doesn't support the following syntax:

  1. withsource=: A saída sempre inclui uma coluna chamada $table do tipo string cujo valor é o nome da tabela da qual cada registro foi recuperado (ou algum nome gerado pelo sistema se a fonte não for uma tabela, mas uma expressão composta).
  2. project=, project-smart: O search operador não suporta essas opções para personalizar as colunas de saída. Em vez disso, ele seleciona automaticamente um conjunto relevante de colunas para a saída, que é equivalente ao conjunto de colunas recuperadas pela project-smart opção no find operador.

Examples

The examples in this article use publicly available tables in the help cluster, such as the StormEvents table in the Samples database.

The examples in this article use publicly available tables, such as the Weather table in the Weather analytics sample gallery. Talvez seja necessário modificar o nome da tabela na consulta de exemplo para corresponder à tabela em seu espaço de trabalho.

O exemplo de followiwing mostra como executar uma pesquisa global de termos. Search for the term Green in all the tables of the ContosoSales database.

The output finds records with the term Green as a last name or a color in the Customers, Products, and SalesTable tables.

 search "Green"

Output

$table CityName ContinentName CustomerKey Education FirstName Gender LastName
Customers Ballard América do Norte 16549 Partial College Mason M Green
Customers Bellingham América do Norte 2070 High School Adam M Green
Customers Bellingham América do Norte 10658 Bachelors Sara F Green
Customers Beverly Hills América do Norte 806 Graduate Degree Richard M Green
Customers Beverly Hills América do Norte 7674 Graduate Degree James M Green
Customers Burbank América do Norte 5241 Graduate Degree Madeline F Green

O exemplo a seguir mostra como executar uma pesquisa de termo global condicional. Search for records that contain the term Green and one of either terms Deluxe or Proseware in the ContosoSales database.

search "Green" and ("Deluxe" or "Proseware")

Output

$table ProductName Manufacturer ColorName ClassName ProductCategoryName
Products Contoso 8GB Relógio & Rádio MP3 Player X850 Verde Contoso, Ltd Green Deluxe Audio
Products Proseware Scan Jet Digital Flat Bed Scanner M300 Verde Proseware, Inc. Green Regular Computers
Products Proseware All-In-One Photo Printer M200 Verde Proseware, Inc. Green Regular Computers
Products Proseware Ink Jet Wireless All-In-One Impressora M400 Verde Proseware, Inc. Green Regular Computers
Products Proseware Ink Jet Instant PDF Sheet-Fed Scanner M300 Verde Proseware, Inc. Green Regular Computers
Products Proseware Desk Jet Impressora All-in-One, Scanner, Copiadora M350 Verde Proseware, Inc. Green Regular Computers
Products Proseware Duplex Scanner M200 Verde Proseware, Inc. Green Regular Computers

O exemplo a seguir demonstra como pesquisar um termo dentro de uma tabela específica. Search for the term Green only in the Customers table.

search in (Products) "Green"

Output

$table ProductName Manufacturer ColorName
Products Contoso 4G MP3 Player E400 Verde Contoso, Ltd Green
Products Contoso 8GB Super-Slim MP3/Video Player M800 Verde Contoso, Ltd Green
Products Contoso 16GB Mp5 Player M1600 Verde Contoso, Ltd Green
Products Contoso 8GB Relógio & Rádio MP3 Player X850 Verde Contoso, Ltd Green
Products NT Wireless Bluetooth Auscultadores Estéreo M402 Verde Northwind Traders Green
Products NT transmissor sem fio e fones de ouvido Bluetooth M150 Verde Northwind Traders Green

O exemplo a seguir demonstra como pesquisar um termo que diferencia maiúsculas de minúsculas. Search for records that match the case-sensitive term in the ContosoSales database.

search kind=case_sensitive "blue"

Output

$table ProductName Manufacturer ColorName ClassName
Products Contoso 16GB Nova Geração MP5 Player M1650 azul Contoso, Ltd blue Regular
Products Contoso Bright Light bateria E20 azul Contoso, Ltd blue Economy
Products Litware 120mm azul LED Case Fan E901 azul Litware, Inc. blue Economy
NewSales Litware 120mm azul LED Case Fan E901 azul Litware, Inc. blue Economy
NewSales Litware 120mm azul LED Case Fan E901 azul Litware, Inc. blue Economy
NewSales Litware 120mm azul LED Case Fan E901 azul Litware, Inc. blue Economy
NewSales Litware 120mm azul LED Case Fan E901 azul Litware, Inc. blue Economy

O exemplo a seguir demonstra como pesquisar um termo em colunas específicas. Search for the terms Aaron and Hughes, in the "FirstName" and "LastName" columns respectively, in the ContosoSales database.

search FirstName:"Aaron" or LastName:"Hughes"

Output

$table CustomerKey Education FirstName Gender LastName
Customers 18285 High School Riley F Hughes
Customers 802 Graduate Degree Aaron M Sharma
Customers 986 Bachelors Melanie F Hughes
Customers 12669 High School Jessica F Hughes
Customers 13436 Graduate Degree Mariah F Hughes
Customers 10152 Graduate Degree Aaron M Campbell

O exemplo a seguir demonstra como pesquisar um termo com um carimbo de data/hora. Search for the term Hughes in the ContosoSales database, if the term appears in a record with a date greater than the given date in 'datetime'.

search "Hughes" and DateKey > datetime('2009-01-01')

Output

$table DateKey SalesAmount_real
SalesTable 2021-12-13T00:00:00Z 446.4715
SalesTable 2021-12-13T00:00:00Z 120.555
SalesTable 2021-12-13T00:00:00Z 48.4405
SalesTable 2021-12-13T00:00:00Z 39.6435
SalesTable 2021-12-13T00:00:00Z 56.9905

Performance Tips

# Tip Prefer Over
1 Prefira usar um único operador de search em vários operadores de search consecutivos search "billg" and ("steveb" or "satyan") pesquisa "billg" | Pesquisar "Steveb" ou "Satyan"
2 Prefira filtrar dentro do operador de search search "billg" and "steveb" pesquisa * | onde * tem "billg" e * tem "steveb"