# `query.nearest_unindexed`

Nearest-neighbour order on a vector with no fixed length.

Area 21, [AI](../topics/ai.md); not declinable; the next step is usually the agent's.

`nearest` on a vector field whose type has no `dimensions:`: a plain
`Vector`, or an `Embedding`, which keeps its vector without a length.
pgvector builds an HNSW index only on a column of fixed length.

```jadpo
/// A reply an agent is still writing, with its meaning as a model made it.
entity DraftReply {
    id: Uuid
    reply_meaning: Vector
}

/// The five replies nearest one being written.
query similar_drafts(reply_meaning: Vector) -> List<Nearest<DraftReply>> {
    from: DraftReply
    order: [DraftReply.reply_meaning nearest reply_meaning]
    limit: 5
}
```

```text
error: `DraftReply.reply_meaning` has no fixed length, so no index can order it by nearness
 --> main.jadpo:10:13
   |
10 |     order: [DraftReply.reply_meaning nearest reply_meaning]
   |             ^^^^^^^^^^^^^^^^^^^^^^^^ a `Vector` without `dimensions:`
  reason: A nearest-neighbour query reads an HNSW index, which pgvector builds only on a vector column of fixed length, and `DraftReply.reply_meaning` is a `Vector`, kept without one.
  next: Give `DraftReply.reply_meaning` a type built on `Vector` with the model's `dimensions:` (agent)
  rule: query.nearest_unindexed
  help: https://jadpo.dev/docs/errors/query.nearest_unindexed

check failed: 1 error, 1 file
```
