> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omni.co/llms.txt
> Use this file to discover all available pages before exploring further.

# fields - Topics

> Restricts which fields can be queried in the topic.

Restricts which fields can be queried in the topic. By default, all fields from the base view and joined views are included.

## Behavior

The `fields` directive enforces restrictions at query runtime, not just in the field browser. Queries attempting to use fields excluded by this directive (or fields that depend on excluded fields) will return an error.

## Syntax

```yaml theme={null}
fields: [<field_selector>, ...]
```

## Properties

<ParamField path="fields" type="string[]">
  An array of field selectors that determine which fields are available in the topic. Supports the following operators:

  | Operator           | Description                                              | Order of operations |
  | ------------------ | -------------------------------------------------------- | ------------------- |
  | `all_views.*`      | Targets all fields from all views in the topic           | 1                   |
  | `view.*`           | Targets all fields in a view                             | 2                   |
  | `tag:<value>`      | Targets fields and views with the specified tag          | 3                   |
  | `view:tag:<value>` | Targets fields with the specified tag in a specific view | 4                   |
  | `view.field`       | Targets a specific field                                 | 5                   |

  Omni will evaluate the operators according to the **Order of operations** value in the above table. This means `all_views` is evaluated first, then specific views, and so on. This allows you to exclude views and then add specific fields back in.

  <Tip>
    To exclude a view, tag, or field, prefix the clause with a `-`. For example: `-users.*`
  </Tip>
</ParamField>

## Examples

```yaml title="Only include the users view" theme={null}
fields: [users.*]
```

```yaml title="Exclude the users view" theme={null}
fields: [all_views.*, -users.*]
```

```yaml title="Exclude only the users.id field" theme={null}
fields: [all_views.*, -users.id]
```

```yaml title="Exclude fields with the pii tag" theme={null}
fields: [all_views.*, -tag:pii]
```

```yaml title="Add the user_facts.lifetime_value back in after excluding the user_facts view" theme={null}
fields: [all_views.*, -user_facts.*, user_facts.lifetime_value]
```

```yaml title="Remove the users.acquisition_cost field from the fields targeted by the marketing tag" theme={null}
fields: [-all_views.*, tag:marketing, -users.acquisition_cost]
```

```yaml title="Include only marketing-tagged fields from the internal__workspaces view" theme={null}
fields: [internal__workspaces:tag:marketing]
```

```yaml title="Exclude PII-tagged fields from the users view" theme={null}
fields: [all_views.*, -users:tag:pii]
```

```yaml title="Exclude an entire view but re-include specific tagged fields from that view" theme={null}
fields: [all_views.*, -internal__workspaces.*, internal__workspaces:tag:marketing]
```
