# `search.undeclared`

A query searches an entity by words that has no `search:` section.

Area 16, [Built-in services](../topics/built-in-services.md); not declinable; the next step is usually the agent's.

## Why Jadpo refuses it

A query finds records by words only in the fields its entity's
`search:` lists: that section is where the compiler gets the column of
words it keeps up to date, its index and its language. Without one there
is nothing to search, and Jadpo won't pick the fields for you, since
which fields people search by, and which come first, is the entity's
decision. Here `Todo` has no `search:`:

## What it looks like

main.jadpo:

```jadpo
type TodoTitle = Text {
    max_length: 200
}

entity Todo {
    id: Uuid
    title: TodoTitle
}

type TodoView = Output {
    pick: [Todo.id, Todo.title]
}

query search_todos(phrase: SearchText) -> List<TodoView> {
    from: Todo
    where: Todo matches phrase
    limit: 20
}
```

```text
error: `Todo` has no `search:`, so its records can't be found by words
 --> main.jadpo:16:12
   |
16 |     where: Todo matches phrase
   |            ^^^^^^^^^^^^^^^^^^^ no `search:`
  reason: A query finds records by words only in the fields its entity's `search:` lists, which the compiler indexes; `Todo` has no `search:` section.
  next: Add `search: { fields: [...] language: SearchLanguage.english }` to `Todo`, listing the text fields people search by (agent)
  rule: search.undeclared
  help: https://jadpo.dev/docs/errors/search.undeclared

check failed: 1 error, 1 file
```

`(agent)` at the end of the `next:` line means your coding agent can make
the fix itself.

## How to fix it

**If people should search todos by their titles**, give the entity a
`search:`, listing the text fields they search by, the one counting most
first, and their language:

```jadpo
entity Todo {
    id: Uuid
    title: TodoTitle

    search: {
        fields: [title]
        language: SearchLanguage.english
    }
}
```


The next `jadpo migrate new` adds the column of words and its index, and
the query finds the best matches first.

## Related

- [Search](../topics/search.md)
- [`search.settings_invalid`](search.settings_invalid.md)
