# Filter

### Definition

A filter, in Reflag, is a mechanism that is used to check if entities such as [user](https://docs.reflag.com/product-handbook/concepts/user), [company](https://docs.reflag.com/product-handbook/concepts/company), [event](https://docs.reflag.com/product-handbook/concepts/event), etc. match a set of predicates. Filters can also be aggregated into logical expressions, thus, facilitating advanced use cases.

Reflag support the following filter types:

* [Company attribute](https://docs.reflag.com/product-handbook/company#attributes) filter, that can be used to check company attributes,
* Company [feature metrics](https://docs.reflag.com/product-handbook/feature#metrics) filter, which allows checking for feature metrics applied to a given company,
* [User attribute](https://docs.reflag.com/product-handbook/user#attributes) filter, used to check user attributes,
* [Event attribute](https://docs.reflag.com/product-handbook/event#attributes) filter, used to check event attributes,
* Company [segment](https://docs.reflag.com/product-handbook/concepts/segment) filter, can be used to check a company's membership in a segment,
* [Flag access](https://docs.reflag.com/product-handbook/feature#access) filter, can be used to check whether a company has access to a flag,
* [Gradual rollout](https://docs.reflag.com/feature-rollouts#gradually-roll-out-your-feature) filter, is used in advanced scenarios to evaluate whether a company matches target rollout bracket,
* [Other context](https://docs.reflag.com/product-handbook/targeting-rules#evaluation-context) filter, used when rules can access additional context, in addition to user and company attributes.

### Company attribute filter

This filter can be used to check company attributes against a set predicates. The attributes include the `First seen` and `Last seen` which are maintained by Reflag. You can use any attribute name that your application sent to Reflag.

### Company feature metrics

This filter allows checking company's feature-specific metrics. These metrics include things like `Event count`, `First used`, `Last used`, end etc.

### User attribute filter

This filter can be used to check user attributes against a set predicates. You can use any attribute name that your application sent to Reflag when updating user.

### Event attribute filter

This filter can be used to check event attributes against a set predicates. You can use any attribute name that your application sent to Reflag when sending track events.

### Company segment filter

This filter can be used to check if a given company is (or not) included in a given segment. The filter essentially evaluates the segment's filter against the company.

### Flag access filter

This filter can be used to check if a given company has (or not) access to a given flag. The filter evaluates the flag's targeting rules against the provided company, and assumes skips evaluation of any non-company attribute related filters.

### Gradual rollout filter

This filter is used by feature access targeting when enabling gradual rollout. It will bracket the pool of companies based on a predictable hashing algorithm and check if the company falls within the rollout percentage.

### Other context filter

This filter can be used to check `other` context attributes against a set predicates. You can use any attribute name that your application sends to Reflag when evaluating feature access.

{% hint style="warning" %}

* Company attribute filters using `First seen` and `Last seen` attributes cannot be used in targeting rules,
* Company feature metrics filters are not supported in targeting rules,
* Event attribute filter is only used in event-based feature and automatic feedback surveys,
* Gradual rollout filter is only used in feature access targeting rules,
* Other context filter is only used in feature access targeting rules,

Any filters that build up on on other filters inherit the restrictions of the filters they are based on.
{% endhint %}

### Next steps

* Learn in depth how to use filters in [setup feature access rules](https://docs.reflag.com/product-handbook/feature-rollouts/feature-targeting-rules).
