Skip to content

Use full-text search

Add q to the list URL to read only entries that contain your words. Use it, for example, to find articles from the search box on your site.

  • An API key with the [読み取り](Read) permission. To issue one, see Create API keys and set permissions
  • You can search only collection lists. If you add q to a URL that reads one entry or a single, you get 400

In the examples below, replace <hostname> with the hostname of your environment and <API key> with your API key. The examples use the content type ID “posts”.

Find entries that contain both “Rust” and “入門”. Separate words with spaces.

ターミナルウィンドウ
curl -G https://<hostname>.hakocms.net/api/v1/content/posts \
-H "Authorization: Bearer <API key>" \
--data-urlencode "q=Rust 入門"

Matching entries are returned in items, sorted by relevance. total is the number of matches. The shape is the same as a normal list (Read entries).

{
"items": [
{
"sys": { "id": "rust-intro", "contentType": "posts", "version": 2 },
"title": "Rust 入門"
}
],
"total": 1,
"limit": 20,
"offset": 0
}

The dates in sys are omitted.

The search rules are as follows:

  • The search covers text, text area, and rich text fields. It also searches inside custom and repeater fields
  • Entries that contain all the space-separated words match
  • If q is only symbols or spaces, there is no filtering. All entries are returned
  • Without order, entries are sorted by relevance

Pass the words typed into the search box to q as is. URLSearchParams does the encoding.

async function search(keyword) {
const params = new URLSearchParams({ q: keyword, limit: "10" });
const res = await fetch(
`https://<hostname>.hakocms.net/api/v1/content/posts?${params}`,
{ headers: { Authorization: "Bearer <API key>" } },
);
const { items, total } = await res.json();
return { items, total };
}
console.log(await search("Rust 入門"));

If you only search published entries, you may use a key with only [読み取り](Read) in the browser.

You can use q together with where, order, limit, and offset. Search articles published on or after 2026-10-01, newest first.

ターミナルウィンドウ
curl -G https://<hostname>.hakocms.net/api/v1/content/posts \
-H "Authorization: Bearer <API key>" \
--data-urlencode "q=Rust" \
--data-urlencode 'where=sys.publishedAt >= "2026-10-01"' \
--data-urlencode "order=-sys.publishedAt"

With order, entries are sorted in order’s order, not by relevance. For how to write where and order, see Filter, sort, and paginate.

With preview=true, the search uses draft values (Read drafts).

Put a word from an entry’s body in the admin into q. If that entry is returned in items, search works.

If nothing matches, check the following:

  • Whether the entry is [公開中](Published). Draft values are not searched without preview=true
  • Whether the words are in text, text area, or rich text fields. Fields such as number and select are not searched
  • Whether the entry contains all the space-separated words