Udostępnij przez


search operator

Applies to: ✅Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Wyszukuje wzorzec tekstu w wielu tabelach i kolumnach.

Note

If you know the specific tables and columns you want to search, it's more performant to use the union and where operators. Operator search może być powolny podczas wyszukiwania dużej liczby tabel i kolumn.

Syntax

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

Learn more about syntax conventions.

Parameters

Name Typ 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 Flaga, która kontroluje zachowanie wszystkich string operatorów skalarnych, takich jak has, w odniesieniu do poufności wielkości liter. Prawidłowe wartości to default, , case_insensitivecase_sensitive. Opcje default i case_insensitive są synonimami, ponieważ zachowanie domyślne jest bez uwzględniania wielkości liter.
TableSources string Rozdzielona przecinkami lista "wieloznacznych" nazw tabel do udziału w wyszukiwaniu. 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 ✔️ Wyrażenie logiczne, które ma być oceniane dla każdego rekordu w danych wejściowych. Jeśli zwraca truewartość , rekord jest zwracany. Zobacz Składnia predykatu wyszukiwania.

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.

Składnia predykatu wyszukiwania

The SearchPredicate allows you to search for specific terms in all columns of a table. Operator zastosowany do terminu wyszukiwania zależy od obecności i umieszczania gwiazdki wieloznacznych (*) w okresie, jak pokazano w poniższej tabeli.

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

Możesz również ograniczyć wyszukiwanie do określonej kolumny, wyszukać dokładne dopasowanie zamiast dopasowania terminu lub wyszukać według wyrażenia regularnego. Składnia dla każdego z tych przypadków jest wyświetlana w poniższej tabeli.

Syntax Explanation
ColumnName:StringLiteral Ta składnia może służyć do ograniczenia wyszukiwania do określonej kolumny. Domyślne zachowanie polega na wyszukiwaniu wszystkich kolumn.
ColumnName==StringLiteral Ta składnia może służyć do wyszukiwania dokładnych dopasowań kolumny względem wartości ciągu. Domyślne zachowanie polega na wyszukaniu dopasowania terminu.
Columnmatches regexStringLiteral This syntax indicates regular expression matching, in which StringLiteral is the regex pattern.

Użyj wyrażeń logicznych, aby połączyć warunki i tworzyć bardziej złożone wyszukiwania. Na przykład "error" and x==123 spowoduje to wyszukanie rekordów, które mają termin error w dowolnych kolumnach i wartość 123 w kolumnie x .

Przykłady składni predykatu wyszukiwania

# Syntax Znaczenie (równoważne where) Comments
1 search "err" where * has "err"
2 search in (T1,T2,A*) "err" union T1,T2,A* | gdzie * ma wartość "err"
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 W przypadku wszystkich porównań ciągów uwzględniana jest wielkość liter
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=: Dane wyjściowe zawsze zawierają kolumnę o nazwie $table typu string, której wartością jest nazwa tabeli, z której pobrano każdy rekord (lub nazwa wygenerowana przez system, jeśli źródło nie jest tabelą, ale wyrażeniem złożonym).
  2. project=, project-smart: search Operator nie obsługuje tych opcji dostosowywania kolumn wyjściowych. Zamiast tego automatycznie wybiera odpowiedni zestaw kolumn dla danych wyjściowych, który jest odpowiednikiem zestawu kolumn pobranych przez project-smart opcję w operatorze find .

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. Może być konieczne zmodyfikowanie nazwy tabeli w przykładowym zapytaniu, aby było zgodne z tabelą w obszarze roboczym.

W poniższym przykładzie pokazano, jak wykonać globalne wyszukiwanie terminów. 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 Ameryka Północna 16549 Partial College Mason M Green
Customers Bellingham Ameryka Północna 2070 High School Adam M Green
Customers Bellingham Ameryka Północna 10658 Bachelors Sara F Green
Customers Beverly Hills Ameryka Północna 806 Graduate Degree Richard M Green
Customers Beverly Hills Ameryka Północna 7674 Graduate Degree James M Green
Customers Burbank Ameryka Północna 5241 Graduate Degree Madeline F Green

W poniższym przykładzie pokazano, jak wykonać warunkowe wyszukiwanie terminów globalnych. 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 Zegar Contoso 8GB & Radio MP3 Odtwarzacz X850 Zielony Contoso, Ltd Green Deluxe Audio
Products Proseware Scan Jet Digital Flat Bed Skaner M300 Zielony Proseware, Inc. Green Regular Computers
Products Proseware All-In-One Photo Printer M200 Green Proseware, Inc. Green Regular Computers
Products Proseware Ink Jet Wireless All-In-One Drukarka M400 Zielony Proseware, Inc. Green Regular Computers
Products Proseware Ink Jet Instant PDF Sheet-Fed Skaner M300 Zielony Proseware, Inc. Green Regular Computers
Products Proseware Desk Jet All-in-One Printer, Skaner, Kopiarka M350 Zielony Proseware, Inc. Green Regular Computers
Products Proseware Duplex Skaner M200 Zielony Proseware, Inc. Green Regular Computers

W poniższym przykładzie pokazano, jak wyszukać termin w określonej tabeli. 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 Green Contoso, Ltd Green
Products Contoso 8GB Super-Slim MP3/Video Player M800 Green Contoso, Ltd Green
Products Contoso 16GB Mp5 Player M1600 Green Contoso, Ltd Green
Products Zegar Contoso 8GB & Radio MP3 Odtwarzacz X850 Zielony Contoso, Ltd Green
Products Słuchawki stereo Bluetooth NT NT M402 Green Northwind Traders Green
Products Nadajnik bezprzewodowy NT i słuchawki Bluetooth M150 Green Northwind Traders Green

W poniższym przykładzie pokazano, jak wyszukać termin z uwzględnieniem wielkości liter. 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 New Generation MP5 Player M1650 niebieski Contoso, Ltd blue Regular
Products Contoso Bright Light baterii E20 niebieski Contoso, Ltd blue Economy
Products Litware 120mm Niebieski wentylator LED E901 niebieski Litware, Inc. blue Economy
NewSales Litware 120mm Niebieski wentylator LED E901 niebieski Litware, Inc. blue Economy
NewSales Litware 120mm Niebieski wentylator LED E901 niebieski Litware, Inc. blue Economy
NewSales Litware 120mm Niebieski wentylator LED E901 niebieski Litware, Inc. blue Economy
NewSales Litware 120mm Niebieski wentylator LED E901 niebieski Litware, Inc. blue Economy

W poniższym przykładzie pokazano, jak wyszukiwać termin w określonych kolumnach. 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

W poniższym przykładzie pokazano, jak wyszukiwać termin ze znacznikiem czasu. 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 Preferuj używanie jednego search operatora w kilku kolejnych search operatorach search "billg" and ("steveb" or "satyan") wyszukiwanie "billg" | wyszukiwanie "steveb" lub "satyan"
2 Preferuj search filtrowanie wewnątrz operatora search "billg" and "steveb" wyszukiwanie * | gdzie * ma "billg" i * ma "steveb"