Skip to main content

Segment Rule Operators

Segment rule operators in Flagsmith allow you to define how trait values are compared when evaluating segment membership. Note that all operators are case-sensitive.

NameDescription
Exactly Matches (=)Trait value is equal to the rule value
Does not match (!=)Trait value is not equal to the rule value
% SplitIdentity is in the percentage bucket. Learn more
>Trait value is greater than the rule value
>=Trait value is greater than or equal to the rule value
<Trait value is less than the rule value
<=Trait value is less than or equal to the rule value
InTrait value is equal to any element in a comma-separated list (case-sensitive). Learn more
ContainsRule value is a substring of the trait value
Does not containRule value is not a substring of the trait value
Matches regexTrait value matches the given regular expression
Is setTrait value is set for the given identity and trait key
Is not setTrait value is not set for the given identity and trait key
SemVerTrait value is compared against the rule value according to Semantic Versioning. Learn more

Operator details

The In operator enables you to match a trait value against a comma-separated list of values. For example, the segment rule value might read 21,682,8345. This would match against a trait value of 682 but not against a trait value of 683 or 834.

The In operator can be useful for building segments that represent a specific set of tenants in your application. For example, you could create a segment with the following rule: tenant_id In tenant_1,tenant_2,tenant_3

Minimum SDK versions for local evaluation mode

When running in local evaluation mode, SDK clients evaluate segment rules locally, which means they must be updated to support the latest operators.

If an SDK client tries to evaluate a segment rule that has an unrecognised operator, that rule will silently evaluate to false. The table below lists the minimum required SDK version required by each operator:

ModuloIn
Python2.3.03.3.0
Java5.1.07.1.0
.NET4.2.05.0.0
Node.js2.4.02.5.0
Ruby3.1.03.2.0
PHP3.1.04.1.0
Go2.2.03.1.0
Rust0.2.01.3.0
Elixir1.1.02.0.0

Limits

These are the default limits for segments and rules:

  • 100 segments per project
  • 100 segment overrides per environment
  • 100 rules per segment override
  • 1000 bytes per segment rule value

See the documentation on System Limits for more details.

Custom fields

Optional or required custom fields can be defined when creating or updating segments. Learn more