Understand Filter Expressions and their structure
masterIn Shoko Server, a FilterExpression is a data transformation method that takes zero or more arguments and returns a result. These expressions are structured as a Binary Expression Tree.
Key constraints for designing expressions:
- Argument Limit: An expression should not have more than 5 arguments of any single type. If an expression requires more, it should be redesigned (e.g., instead of one large function, use nested logic like
And(HasTag("comedy"), HasTag("action"))). - Complexity: Expressions should be kept as simple as possible. For example,
NANDlogic should be expressed asNot(And())rather than a dedicated operator, unless the complexity exceeds 2 or 3 operations. - Supported Argument Types: Arguments must be one of the following types (which can be mapped to other CLR types like enums):
StringDouble(integers are coerced toDouble)DateTime
// Example of a nested FilterExpression structure:
And(Or(HasTag('comedy'), HasTag('action')), Not(HasTag('18 restricted')))