全部產品
Search
文件中心

ApsaraDB for SelectDB:AI_FILTER

更新時間:Feb 04, 2026

根據給定條件對文本進行過濾。

文法

AI_FILTER([<resource_name>], <text>)

參數

參數

說明

<resource_name>

指定的資源名稱,可空

<text>

判斷的資訊

傳回值

  • 返回一個布爾值。

  • 當輸入有值為 NULL 時返回 NULL。

  • 結果為大模型產生,所以返回內容並不固定。

樣本

假設我有如下表,代表某家快遞公司收到的評論:

CREATE TABLE user_comments (
    id      INT,
    comment VARCHAR(500)
) DUPLICATE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 10
PROPERTIES (
    "replication_num" = "1"
);

當我想查詢其中的好評時可以:

SELECT id, comment FROM user_comments
WHERE  AI_FILTER('resource_name', CONCAT('This is a positive comment: ', comment));

結果大致如下:

+------+--------------------------------------------+
| id   | comment                                    |
+------+--------------------------------------------+
|    1 | Absolutely fantastic, highly recommend it. |
|    3 | This product is amazing and I love it.     |
+------+--------------------------------------------+