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

# Scalar

> Index scalar fields for filtering, sorting, aggregates, and joins

Scalar fields hold individual values such as numbers, booleans, dates, and UUIDs.
Include the columns used for filtering, sorting, grouping, aggregates, and join
keys in the same ParadeDB index as your search fields.

These fields are indexed using ParadeDB's columnar format by default.
This enables fast [filtering pushdown](https://www.paradedb.com/docs/reference/filtering-and-sorting/filtering/indexed.md#filter-pushdown), [Top K ordering](https://www.paradedb.com/docs/reference/filtering-and-sorting/top-k.md), and
[aggregates](https://www.paradedb.com/docs/reference/aggregates/overview.md) over these columns. For example, in the following index definition, `rating` and `id` are columnar indexed
because they are integers, whereas `description` is not because it is text.

```sql SQL theme={null}
CREATE INDEX search_idx ON mock_items
USING paradedb (id, description, rating);
```

```ts Drizzle theme={null}
import { indexing } from "@paradedb/drizzle-paradedb";

indexing
  .paradedbIndex("search_idx")
  .on(mockItems.id, mockItems.description, mockItems.rating);
```

```python Django theme={null}
from django.db import connection
from paradedb.indexes import ParadeDBIndex

with connection.schema_editor() as schema_editor:
    schema_editor.add_index(
        MockItem,
        ParadeDBIndex(
            fields={
                "id": {},
                "description": {},
                "rating": {},
            },
            name="search_idx",
        ),
    )
```

```python SQLAlchemy theme={null}
from sqlalchemy import Index
from paradedb.sqlalchemy import indexing

idx = Index(
    "search_idx",
    indexing.ParadeDBField(MockItem.id),
    indexing.ParadeDBField(MockItem.description),
    indexing.ParadeDBField(MockItem.rating),
    postgresql_using="paradedb",
)

with engine.begin() as conn:
    idx.create(conn)
```

```ruby Rails theme={null}
ActiveRecord::Base.connection.add_paradedb_index(
  :mock_items,
  fields: {
    id: {},
    description: {},
    rating: {}
  },
  name: :search_idx
)
```

```cs EF Core theme={null}
modelBuilder.Entity<MockItem>()
    .HasParadeDbIndex("search_idx", e => e.Id)
    .HasField(e => e.Description)
    .HasField(e => e.Rating);
```

## Text and JSON Values

For exact text filters and text sort keys, use the
[literal](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/literal.md) or
[literal normalized](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/literal-normalized.md)
tokenizer. Both enable columnar storage by default. See
[Indexed Columns](https://www.paradedb.com/docs/reference/filtering-and-sorting/filtering/indexed.md#text-columns) for supported filter
operators and [Sorting by Text](https://www.paradedb.com/docs/reference/filtering-and-sorting/top-k.md#sorting-by-text) for
ordering requirements.

To enable columnar indexing for other text and JSON columns, cast the column to a [tokenizer](https://www.paradedb.com/docs/reference/tokenizers/overview.md) with `columnar` set to `true`.

```sql SQL theme={null}
CREATE INDEX search_idx ON mock_items
USING paradedb (id, (description::pdb.unicode_words('columnar=true')), rating);
```

```ts Drizzle theme={null}
import { indexing, tokenizer } from "@paradedb/drizzle-paradedb";

indexing
  .paradedbIndex("search_idx")
  .on(
    mockItems.id,
    indexing.paradedbField(
      mockItems.description,
      tokenizer.unicodeWords({ columnar: true }),
    ),
    mockItems.rating,
  );
```

```python Django theme={null}
from django.db import connection
from paradedb.indexes import ParadeDBIndex
from paradedb.search import Tokenizer

with connection.schema_editor() as schema_editor:
    schema_editor.add_index(
        MockItem,
        ParadeDBIndex(
            fields={
                "id": {},
                "description": {
                    "tokenizer": Tokenizer.unicode_words(
                        options={"columnar": True}
                    ),
                },
                "rating": {},
            },
            name="search_idx",
        ),
    )
```

```python SQLAlchemy theme={null}
from sqlalchemy import Index
from paradedb.sqlalchemy import indexing, tokenizer

idx = Index(
    "search_idx",
    indexing.ParadeDBField(MockItem.id),
    indexing.ParadeDBField(
        MockItem.description,
        tokenizer=tokenizer.unicode_words(options={"columnar": True}),
    ),
    indexing.ParadeDBField(MockItem.rating),
    postgresql_using="paradedb",
)

with engine.begin() as conn:
    idx.create(conn)
```

```ruby Rails theme={null}
ActiveRecord::Base.connection.add_paradedb_index(
  :mock_items,
  fields: {
    id: {},
    description: {
      tokenizer: ParadeDB::Tokenizer.unicode_words(options: { columnar: true })
    },
    rating: {}
  },
  name: :search_idx
)
```

```cs EF Core theme={null}
modelBuilder.Entity<MockItem>()
    .HasParadeDbIndex("search_idx", e => e.Id)
    .HasField(e => e.Description, Tokenizer.Unicode(new() { ["columnar"] = true }))
    .HasField(e => e.Rating);
```

> [!NOTE]
>
> The `columnar` option for tokenizers is available in versions `0.22.0` and
> above.

Columnar defaults to `false` for all tokenizers besides [literal](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/literal.md) and
[literal normalized](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/literal-normalized.md), which default to
`true` and do not require an explicit setting.

The reason is that tokenized columns can represent large documents and would be expensive to store column-wise,
whereas literal and literal normalized columns are typically single-value and much more compact.

> [!NOTE]
>
> The columnar value stores the raw text value regardless of the tokenizer. For example, if `Hello world` is
> split into tokens `hello` and `world`, the columnar value remains `Hello world`.
>
> This is important because operations like filtering and sorting require the original column value, not the tokens.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.