filter_item
filter_item(item, ctx) runs once per item. Return the item to keep it, or nil to drop it before it reaches the database.
Mutually exclusive with keyword filter. If filter_item() exists in your script, the built-in keyword filter is skipped entirely, even if you have keywords in your config.
Signature
Section titled “Signature”function filter_item(item, ctx) -> table | nilParameters
Section titled “Parameters”| Field | Type | Mutable | Description |
|---|---|---|---|
item.fields |
table (string→string) | yes | Item fields |
item.matches |
array of strings | no | Matched keywords (read-only) |
Returns
Section titled “Returns”| Return | Effect |
|---|---|
| Item table | Keep this item |
nil / false |
Drop this item |
Example
Section titled “Example”function filter_item(item, ctx) local title = (item.fields.title or ""):lower()
-- Drop unwanted items if title == "" or title:find("sponsored") then return nil end
-- Mutate fields before storage item.fields.title = title:sub(1,1):upper() .. title:sub(2)
return itemendSee Also
Section titled “See Also”- after_extract - Batch filter/modify all items
- before_store - Last chance before DB insert