# search

Source: https://zotonic.com/docs/1844/search

URI: https://zotonic.com/id/1844

Language: en



The m\_search model provides access to different kinds of search queries for searching through models.

Most searches in Zotonic are implemented in the <a href="/id/doc_module_mod_search" class="doc-reference doc-reference-module"><code>module#mod_search</code></a> module, searching through the `rsc` table in different kinds of ways.

Though, any module can implement a search by observing the `search_query` notification.

The search module is used inside templates. For example, the following snippet fetches the latest 10 modified pages in the "text" category:

```django
{% for id in m.search[{latest cat="text" pagelen=10}] %}
    {{ m.rsc[id].title }}
{% endfor %}
```

Another example, searching for a text and requesting the second page with 20 results at a time:

```django
{% for id, rank in m.search.paged[{fulltext text=query_string page=2 pagelen=20}] %}
    {{ m.rsc[id].title }}
{% endfor %}
```

Available Model API Paths
-------------------------

| Method | Path pattern                         | Description                                                                      |
| ------ | ------------------------------------ | -------------------------------------------------------------------------------- |
| `get`  | `/paged/+searchname/...`             | Run named search `+searchname` with request arguments and return paged search results. |
| `get`  | `/count/+searchname/...`             | Run named search `+searchname` and return only the total match count.            |
| `get`  | `/paged/+name_props_searchprops/...` | Run deprecated tuple-style search (`{Name, Props}`) and return paged results.    |
| `get`  | `/+name_props_searchprops/...`       | Run deprecated tuple-style search (`{Name, Props}`) and return non-paged results. |
| `get`  | `/paged`                             | Run search from payload/query arguments and return paged results. No further lookups. |
| `get`  | `/count`                             | Run search from payload/query arguments and return only the count. No further lookups. |
| `get`  | `/+searchname/...`                   | Run named search `+searchname` with request arguments and return results.        |
| `get`  | `/`                                  | Run search from payload/query arguments using the default search handling. No further lookups. |

`/+name` marks a variable path segment. A trailing `/...` means extra path segments are accepted for further lookups.

HTTP API example
----------------

The following request finds events, orders them by their start date, and returns the title, summary, start date, and end date for the first 20 results:

```shell
curl --get 'https://example.com/api/model/search/get/paged' \
  --header 'Accept: application/json' \
  --data-urlencode 'cat=event' \
  --data-urlencode 'sort=pivot.date_start' \
  --data-urlencode 'page=1' \
  --data-urlencode 'pagelen=20' \
  --data-urlencode 'options.properties=title,summary,date_start,date_end'
```

The `options.properties` argument expands every result id into a resource property map. The `id` property is always included. Without this option, the `result` array contains resource ids. An abbreviated response is:

```json
{
  "result": [
    {
      "id": 123,
      "title": {
        "_type": "trans",
        "tr": { "en": "Open Studio" }
      },
      "summary": {
        "_type": "trans",
        "tr": { "en": "An afternoon with local artists." }
      },
      "date_start": "2026-09-12T13:00:00Z",
      "date_end": "2026-09-12T17:00:00Z"
    }
  ]
}
```

The dates are returned as ISO 8601 UTC values. On multilingual sites, translated properties such as `title` and `summary` are returned as translation objects. Add `unfinished=true` to restrict the results to ongoing and future events.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1844?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1844?language=en>)
