Query filters
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ใช้ข้อกำหนดของตัวกรองการค้นหาด้านล่างในคำขอ API ที่มีความสามารถในการกรอง
สตริงตัวกรองต้องระบุเป็นนิพจน์หรือรายการนิพจน์
นิพจน์แบบง่าย
ต้องระบุตัวกรองโดยใช้ไวยากรณ์ต่อไปนี้
นิพจน์จะมีรูปแบบทั่วไปดังนี้
<expr> |
::= |
<field> <operator> <value> |
<field>
เป็น string
เมื่อ <field>
มีการเว้นวรรคหรือเครื่องหมายโคลอนจะต้องใส่เครื่องหมายคำพูดคู่คร่อมอยู่
<operator>
อาจเป็นโอเปอเรเตอร์ความเท่าเทียมหรือโอเปอเรเตอร์เชิงสัมพันธ์และทำตามข้อกำหนดด้านล่างนี้
โอเปอเรเตอร์ความเท่าเทียม "="
กำหนดไว้สำหรับช่องสตริงเท่านั้น
กำหนดโอเปอเรเตอร์การจับคู่คำนำหน้า ":"
สำหรับช่องสตริงเท่านั้น
กำหนดโอเปอเรเตอร์เชิงสัมพันธ์ "<" | ">" | "<=" | ">="
สำหรับช่องการประทับเวลาเท่านั้น
<value>
ที่ระบุควรเป็น string
ซึ่งอาจอยู่ในรูปแบบ Timestamp
โดยขึ้นอยู่กับ <field>
เมื่อ <value>
มีการเว้นวรรคหรือเครื่องหมายโคลอน คุณจะต้องใส่เครื่องหมายคำพูดคู่คร่อมอยู่
รายการนิพจน์
ระบบอาจผนวกนิพจน์เพื่อสร้างการค้นหาที่ซับซ้อนขึ้น ข้อกำหนดของ BNF มีดังนี้
<exprList> |
::= |
<expr> |
<exprList> <conjunction> <expr> |
<negation> <expr>
|
<conjunction> |
::= |
"AND" | "OR" | "" |
<negation> |
::= |
"NOT" |
การใช้สตริงว่างเป็นคำสันธานจะทำหน้าที่เป็น AND โดยนัย
ลำดับความสำคัญของการดำเนินการผนวกจากสูงสุดไปต่ำสุดคือ NOT, AND, OR
ตัวอย่าง
โปรดดูตัวอย่างตัวกรองด้านล่างนี้ โปรดทราบว่าช่องจริงที่รองรับอาจแตกต่างกันไปตาม API เวอร์ชันต่างๆ สำหรับคอลัมน์ตัวกรองที่พร้อมใช้งานใน v1beta1
โปรดดูที่นี่
วิธีค้นหาการแจ้งเตือนทั้งหมดที่สร้างขึ้นในวันที่ 5 เมษายน 2018 หรือหลังจากนั้น
createTime >= "2018-04-05T00:00:00Z"
วิธีค้นหาการแจ้งเตือนทั้งหมดจากแหล่งที่มา "ฟิชชิงใน Gmail"
source="Gmail phishing"
วิธีค้นหาการแจ้งเตือนทั้งหมดจากแหล่งที่มาที่ขึ้นต้นด้วย "Gmail":
source:"Gmail"
วิธีค้นหาการแจ้งเตือนทั้งหมดที่เริ่มต้นในปี 2017
startTime >= "2017-01-01T00:00:00Z" AND startTime <
"2018-01-01T00:00:00Z"
วิธีค้นหาการแจ้งเตือนฟิชชิงจากต้นทางทั้งหมดที่ "Gmail" รายงาน
type="User reported phishing" source="Gmail phishing"
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-03-25 UTC
[null,null,["อัปเดตล่าสุด 2025-03-25 UTC"],[],[],null,["# Query filters\n\nUse the query filter specs below in API requests that provide filtering capabilities.\nThe filter string must be specified as an expression or list of expressions.\n\nSimple expressions\n------------------\n\nFilters must be specified using the following grammar:\n\nAn expression has the general form:\n\n|----------|---------|------------------------------|\n| `\u003cexpr\u003e` | ` ::= ` | `\u003cfield\u003e \u003coperator\u003e \u003cvalue\u003e` |\n\n- `\u003cfield\u003e` is a `string`. When `\u003cfield\u003e` contains a space or a colon must be enclosed by double quotes.\n- `\u003coperator\u003e` could be equality or relational operators, and follows specification as below: \n The equality operator `\"=\"` is defined only for string fields. \n The prefix match operator `\":\"` is defined only for string fields. \n The relational operators `\"\u003c\" | \"\u003e\" | \"\u003c=\" | \"\u003e=\"` are defined only for timestamp fields. \n- The `\u003cvalue\u003e` supplied should be `string` that may be in [Timestamp](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp) format depending on the `\u003cfield\u003e`. When `\u003cvalue\u003e` contains a space or a colon it must be enclosed in double quotes.\n\n\u003cbr /\u003e\n\nExpression lists\n----------------\n\nExpressions may be joined to form a more complex query. The BNF specification is: \n\n|-----------------|---------|----------------------------------------------------------------------|\n| `\u003cexprList\u003e` | ` ::= ` | `\u003cexpr\u003e |` ` \u003cexprList\u003e \u003cconjunction\u003e \u003cexpr\u003e |` ` \u003cnegation\u003e \u003cexpr\u003e` |\n| `\u003cconjunction\u003e` | ` ::= ` | `\"AND\" | \"OR\" | \"\"` |\n| `\u003cnegation\u003e` | ` ::= ` | `\"NOT\"` |\n\nUsing the empty string as a conjunction acts as an implicit AND. \nThe precedence of joining operations, from highest to lowest, is NOT, AND, OR.\n\n\u003cbr /\u003e\n\nExamples\n--------\n\nGiven below are some example filters. Note that the actual fields supported may vary between\nthe different versions of the API. For filter columns available in `v1beta1` see [here](/workspace/admin/alertcenter/reference/filter-fields).\n\nTo query for all alerts created on or after April 5, 2018: \n\n`createTime \u003e= \"2018-04-05T00:00:00Z\"` \n\n\nTo query for all alerts from the source \"Gmail phishing\": \n\n`source=\"Gmail phishing\"` \n\n\nTo query for all alerts from a source which starts with \"Gmail\": \n\n`source:\"Gmail\"` \n\n\nTo query for all alerts which started in 2017: \n\n`startTime \u003e= \"2017-01-01T00:00:00Z\" AND startTime \u003c\n\"2018-01-01T00:00:00Z\"` \n\n\nTo query for all user reported phishing alerts from the source \"Gmail phishing\": \n\n`type=\"User reported phishing\" source=\"Gmail phishing\"`"]]