---
title: Indexing Text Arrays
description: Add text arrays to the index
canonical: https://docs.paradedb.com/documentation/indexing/indexing-arrays
---

The BM25 index accepts arrays of type `text[]` or `varchar[]`.

```sql
CREATE TABLE array_demo (id SERIAL PRIMARY KEY, categories TEXT[]);
INSERT INTO array_demo (categories) VALUES
    ('{"food","groceries and produce"}'),
    ('{"electronics","computers"}'),
    ('{"books","fiction","mystery"}');

CREATE INDEX ON array_demo USING bm25 (id, categories)
WITH (key_field = 'id');
```

Under the hood, each element in the array is indexed as a separate entry. This means that an array is considered a
match if **any** of its entries is a match.

```sql
SELECT * FROM array_demo WHERE categories === 'food';
```

```ini Expected Response
 id |           categories
----+--------------------------------
  1 | {food,"groceries and produce"}
(1 row)
```

Text arrays can be [tokenized](/documentation/tokenizers) and [filtered](/documentation/token-filters) in the same way as text fields:

```sql
CREATE INDEX ON array_demo USING bm25 (id, (categories::pdb.literal))
WITH (key_field = 'id');
```
