Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Applies to: ✅Microsoft Fabric✅Azure Data Explorer✅Azure Monitor✅Microsoft Sentinel
Söker i ett textmönster i flera tabeller och kolumner.
Note
If you know the specific tables and columns you want to search, it's more performant to use the union and where operators. Operatorn search kan vara långsam när du söker i ett stort antal tabeller och kolumner.
Syntax
[T|] search [kind=CaseSensitivity ] [in(TableSources)] SearchPredicate
Learn more about syntax conventions.
Parameters
| Name | Type | 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 |
En flagga som styr beteendet för alla string skaläroperatorer, till exempel has, med avseende på skiftlägeskänslighet. Giltiga värden är default, case_insensitive, case_sensitive. Alternativen default och case_insensitive är synonyma, eftersom standardbeteendet är skiftlägesokänsligt. |
|
| TableSources | string |
En kommaavgränsad lista över "jokertecken" tabellnamn som ska delta i sökningen. 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 |
✔️ | Ett booleskt uttryck som ska utvärderas för varje post i indata. Om den returnerar truematas posten ut. Se Sökpredikatsyntax. |
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.
Syntax för sökpredikat
The SearchPredicate allows you to search for specific terms in all columns of a table. Operatorn som tillämpas på en söktermen beror på förekomsten och placeringen av en jokerteckenasterisk (*) i termen enligt följande tabell.
| Literal | Operator |
|---|---|
billg |
has |
*billg |
hassuffix |
billg* |
hasprefix |
*billg* |
contains |
bi*lg |
matches regex |
Du kan också begränsa sökningen till en specifik kolumn, söka efter en exakt matchning i stället för en termmatchning eller söka efter reguljära uttryck. Syntaxen för vart och ett av dessa fall visas i följande tabell.
| Syntax | Explanation |
|---|---|
ColumnName:StringLiteral |
Den här syntaxen kan användas för att begränsa sökningen till en specifik kolumn. Standardbeteendet är att söka i alla kolumner. |
ColumnName==StringLiteral |
Den här syntaxen kan användas för att söka efter exakta matchningar av en kolumn mot ett strängvärde. Standardbeteendet är att söka efter en termmatchning. |
Columnmatches regexStringLiteral |
This syntax indicates regular expression matching, in which StringLiteral is the regex pattern. |
Använd booleska uttryck för att kombinera villkor och skapa mer komplexa sökningar. Till exempel skulle "error" and x==123 resultera i en sökning efter poster som har termen error i alla kolumner och värdet 123 i kolumnen x.
Exempel på predikatsyntax för sökning
| # | Syntax | Betydelse (motsvarande where) |
Comments |
|---|---|---|---|
| 1 | search "err" |
where * has "err" |
|
| 2 | search in (T1,T2,A*) "err" |
union T1,T2,A* | där * har "fel" |
|
| 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 |
Alla strängjämförelser är skiftlägeskänsliga | |
| 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:
-
withsource=: Utdata innehåller alltid en kolumn med namnet$tableav typenstringvars värde är tabellnamnet som varje post hämtades från (eller något systemgenererat namn om källan inte är en tabell utan ett sammansatt uttryck). -
project=,project-smart: Operatornsearchstöder inte dessa alternativ för att anpassa utdatakolumnerna. I stället väljer den automatiskt en relevant uppsättning kolumner för utdata, vilket motsvarar den uppsättning kolumner som hämtas avproject-smartalternativet i operatornfind.
Examples
The examples in this article use publicly available tables in the help cluster, such as the
StormEventstable in the Samples database.
The examples in this article use publicly available tables, such as the
Weathertable in the Weather analytics sample gallery. Du kan behöva ändra tabellnamnet i exempelfrågan för att matcha tabellen på din arbetsyta.
Följande exempel visar hur du kör en global termsökning. 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 | North America | 16549 | Partial College | Mason | M | Green |
| Customers | Bellingham | North America | 2070 | High School | Adam | M | Green |
| Customers | Bellingham | North America | 10658 | Bachelors | Sara | F | Green |
| Customers | Beverly Hills | North America | 806 | Graduate Degree | Richard | M | Green |
| Customers | Beverly Hills | North America | 7674 | Graduate Degree | James | M | Green |
| Customers | Burbank | North America | 5241 | Graduate Degree | Madeline | F | Green |
I följande exempel visas hur du kör en villkorlig global termsökning. 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 Klocka & Radio MP3 Player X850 Grön | Contoso, Ltd | Green | Deluxe | Audio |
| Products | Proseware Scan Jet Digital Flat Bed Scanner M300 Green | 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 Skrivare M400 Grön | Proseware, Inc. | Green | Regular | Computers |
| Products | Proseware Ink Jet Instant PDF Sheet-Fed Scanner M300 Green | Proseware, Inc. | Green | Regular | Computers |
| Products | Proseware Desk Jet Allt-i-ett-skrivare, skanner, kopiator M350 Grön | Proseware, Inc. | Green | Regular | Computers |
| Products | Proseware Duplex Scanner M200 Green | Proseware, Inc. | Green | Regular | Computers |
I följande exempel visas hur du söker efter en term i en viss tabell.
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 8 GB Super-Slim MP3/Video Player M800 Green | Contoso, Ltd | Green |
| Products | Contoso 16GB Mp5 Player M1600 Green | Contoso, Ltd | Green |
| Products | Contoso 8GB Klocka & Radio MP3 Player X850 Grön | Contoso, Ltd | Green |
| Products | NT Wireless Bluetooth Stereo Hörlurar M402 Grön | Northwind Traders | Green |
| Products | NT Trådlös sändare och Bluetooth Hörlurar M150 Grön | Northwind Traders | Green |
I följande exempel visas hur du söker efter en skiftlägeskänslig term. 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 Ny generation MP5 Player M1650 blå | Contoso, Ltd | blue | Regular |
| Products | Contoso Bright Light batteri E20 blå | Contoso, Ltd | blue | Economy |
| Products | Litware 120mm Blå LED Fall Fläkt E901 blå | Litware, Inc. | blue | Economy |
| NewSales | Litware 120mm Blå LED Fall Fläkt E901 blå | Litware, Inc. | blue | Economy |
| NewSales | Litware 120mm Blå LED Fall Fläkt E901 blå | Litware, Inc. | blue | Economy |
| NewSales | Litware 120mm Blå LED Fall Fläkt E901 blå | Litware, Inc. | blue | Economy |
| NewSales | Litware 120mm Blå LED Fall Fläkt E901 blå | Litware, Inc. | blue | Economy |
I följande exempel visas hur du söker efter en term i specifika kolumner. 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 |
I följande exempel visas hur du söker efter en term med en tidsstämpel. 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 | Föredrar att använda en enda search operator över flera på varandra följande search operatorer |
search "billg" and ("steveb" or "satyan") |
sök "billg" | sök "steveb" eller "satyan" |
| 2 | Föredrar att filtrera inuti search-operatorn |
search "billg" and "steveb" |
sökning * | där * har "billg" och * har "steveb" |