Applies to: ✅Microsoft Fabric✅Azure Data Explorer✅Azure Monitor✅Microsoft Sentinel
複数のテーブルと列でテキスト パターンを検索します。
Note
If you know the specific tables and columns you want to search, it's more performant to use the union and where operators.
search
演算子は、多数のテーブルと列を検索するときに低速になる可能性があります。
Syntax
[T|
] search
[kind=
CaseSensitivity ] [in
(
TableSources)
] SearchPredicate
Learn more about syntax conventions.
Parameters
Name | タイプ | 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 |
大文字と小文字の区別に関して、string など、すべてのhas スカラー演算子の動作を制御するフラグ。 有効な値は、 default 、 case_insensitive 、 case_sensitive です。 既定の動作では大文字と小文字が区別されないので、 default オプションと case_insensitive オプションは同義です。 |
|
TableSources | string |
検索に参加する "ワイルドカード" テーブル名のコンマ区切りの一覧。 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 |
✔️ | 入力内のすべてのレコードに対して評価されるブール式。
true を返すと、レコードが出力されます。
述語構文の検索を参照してください。 |
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.
検索述語の構文
The SearchPredicate allows you to search for specific terms in all columns of a table. 検索語句に適用される演算子は、次の表に示すように、用語内のワイルドカード アスタリスク (*
) の存在と配置によって異なります。
Literal | Operator |
---|---|
billg |
has |
*billg |
hassuffix |
billg* |
hasprefix |
*billg* |
contains |
bi*lg |
matches regex |
また、検索を特定の列に制限したり、用語の一致ではなく完全一致を検索したり、正規表現で検索したりすることもできます。 これらの各ケースの構文を次の表に示します。
Syntax | Explanation |
---|---|
ColumnName: StringLiteral |
この構文を使用して、検索を特定の列に制限できます。 既定の動作では、すべての列を検索します。 |
ColumnName== StringLiteral |
この構文を使用すると、文字列値に対する列の完全一致を検索できます。 既定の動作では、用語の一致を検索します。 |
Columnmatches regex StringLiteral |
This syntax indicates regular expression matching, in which StringLiteral is the regex pattern. |
ブール式を使用して条件を結合し、より複雑な検索を作成します。 たとえば、"error" and x==123
は、任意の列に用語error
を持つレコードと、123
列にx
値を検索します。
検索述語構文の例
# | Syntax | 意味 (同等の where ) |
Comments |
---|---|---|---|
1 | search "err" |
where * has "err" |
|
2 | search in (T1,T2,A*) "err" |
union T1,T2,A* |ここで* には "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 |
すべての文字列比較で大文字と小文字が区別されます | |
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=
: 出力には常に、$table
型のstring
と呼ばれる列が含まれ、その値は各レコードの取得元のテーブル名 (またはソースがテーブルではなく複合式の場合はシステムによって生成された名前) です。 -
project=
、project-smart
:search
演算子は、出力列をカスタマイズするためのこれらのオプションをサポートしていません。 代わりに、出力に関連する列のセットが自動的に選択されます。これは、project-smart
演算子の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. ワークスペース内のテーブルと一致するように、クエリ例のテーブル名を変更する必要がある場合があります。
次の例は、グローバル用語検索を実行する方法を示しています。 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 | 北米 | 16549 | Partial College | Mason | M | Green |
Customers | Bellingham | 北米 | 2070 | High School | Adam | M | Green |
Customers | Bellingham | 北米 | 10658 | Bachelors | Sara | F | Green |
Customers | Beverly Hills | 北米 | 806 | Graduate Degree | Richard | M | Green |
Customers | Beverly Hills | 北米 | 7674 | Graduate Degree | James | M | Green |
Customers | Burbank | 北米 | 5241 | Graduate Degree | Madeline | F | Green |
次の例は、条件付きグローバル用語検索を実行する方法を示しています。 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 Clock & Radio MP3 Player X850 Green | Contoso, Ltd | Green | Deluxe | Audio |
Products | ProsewareスキャンジェットデジタルフラットベッドスキャナーM300グリーン | Proseware, Inc. | Green | Regular | Computers |
Products | Proseware All-In-One フォト プリンター M200 グリーン | Proseware, Inc. | Green | Regular | Computers |
Products | Proseware Ink Jet Wireless All-In-One Printer M400 Green | Proseware, Inc. | Green | Regular | Computers |
Products | Proseware Ink Jet インスタント PDF Sheet-Fed スキャナー M300 グリーン | Proseware, Inc. | Green | Regular | Computers |
Products | Proseware Desk Jet オールインワン プリンター, スキャナー, コピー機 M350 グリーン | Proseware, Inc. | Green | Regular | Computers |
Products | Proseware 二重スキャナー M200 グリーン | Proseware, Inc. | Green | Regular | Computers |
次の例では、特定のテーブル内の用語を検索する方法を示します。
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 プレーヤー M1600 グリーン | Contoso, Ltd | Green |
Products | Contoso 8GB Clock & Radio MP3 Player X850 Green | Contoso, Ltd | Green |
Products | NTワイヤレスBluetoothステレオヘッドフォンM402グリーン | Northwind Traders | Green |
Products | NTワイヤレス送信機とBluetoothヘッドフォンM150グリーン | Northwind Traders | Green |
次の例では、大文字と小文字を区別する用語を検索する方法を示します。 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 blue | Contoso, Ltd | blue | Regular |
Products | Contoso Bright Light Battery E20 blue | Contoso, Ltd | blue | Economy |
Products | ライトウェア120ミリメートルブルーLEDケースファンE901青 | Litware, Inc. | blue | Economy |
NewSales | ライトウェア120ミリメートルブルーLEDケースファンE901青 | Litware, Inc. | blue | Economy |
NewSales | ライトウェア120ミリメートルブルーLEDケースファンE901青 | Litware, Inc. | blue | Economy |
NewSales | ライトウェア120ミリメートルブルーLEDケースファンE901青 | Litware, Inc. | blue | Economy |
NewSales | ライトウェア120ミリメートルブルーLEDケースファンE901青 | Litware, Inc. | blue | Economy |
次の例では、特定の列で用語を検索する方法を示します。 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 |
次の例では、タイムスタンプを持つ用語を検索する方法を示します。 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 | 複数の連続する search 演算子よりも単一の search 演算子の使用を優先します |
search "billg" and ("steveb" or "satyan") |
"billg" を検索する |検索 "steveb" または "satyan" |
2 |
search 演算子内のフィルター処理を優先します |
search "billg" and "steveb" |
search * |ここで* は "billg" を持ち、* は "steveb" を持っています |