## Index a dataset for retrieval

`datasets.index(strdataset_id, DatasetIndexParams**kwargs)  -> RetrievalIndex`

**post** `/api/v1/datasets/{dataset_id}/retrieval-index`

Embeds the selected text columns of every row so the dataset can be searched. `text_columns` names the columns to search, in the order they are combined into each row’s text. Indexing runs in the background: poll GET /datasets/{dataset_id}/retrieval-index until `status` is `succeeded`, then pass the dataset id in `file_search.dataset_ids` on POST /responses. A dataset has one index. Repeating the request with the same `text_columns` returns the existing index instead of starting another, and different columns return 409. Once an index has `failed`, POST again, with the same or different `text_columns`, to rebuild it.

### Parameters

- `dataset_id: str`

- `text_columns: Sequence[str]`

  Columns whose text is searched, combined into each row’s text in this order. For most uploaded datasets these are the file’s column headers, even after adaptation. An unknown column returns 400 listing the columns that can be indexed.

### Returns

- `class RetrievalIndex: …`

  - `dataset_id: str`

  - `status: Literal["pending", "running", "succeeded", "failed"]`

    The dataset can be searched with `file_search` once this is `succeeded`.

    - `"pending"`

    - `"running"`

    - `"succeeded"`

    - `"failed"`

  - `error: Optional[str]`

    Why indexing failed. Present only when `status` is `failed`.

### Example

```python
import os
from adaption import Adaption

client = Adaption(
    api_key=os.environ.get("ADAPTION_API_KEY"),  # This is the default and can be omitted
)
retrieval_index = client.datasets.index(
    dataset_id="dataset_id",
    text_columns=["question", "answer"],
)
print(retrieval_index.dataset_id)
```

#### Response

```json
{
  "dataset_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "status": "pending",
  "error": "error"
}
```
