Hello,
I am using Ghost (v5.89.0) as a headless CMS on a ReactJS/NextJS website.
Everything is working fine, and I am now developing a search view on the website, but I can’t seem to be able to make the browse posts function to filter by ‘excerpt’ or ‘meta_description’ fields.
It works if I filter for the ‘title’ field but it doesn’t work for the other two.
What are the supported fields on the Content API’s filter function? According to the docs it should be able to filter by any field, right?
Here is my example (anonymized of course)
returns
{
"errors": [
{
"message": "Request not understood error, cannot list posts.",
"context": "Could not understand request.",
"type": "BadRequestError",
"details": null,
"property": null,
"help": null,
"code": "ER_BAD_FIELD_ERROR",
"id": "de632520-5c85-11ef-87ef-857d4a641cd6",
"ghostErrorCode": null
}
]
}
Although I don’t think it’s that important here is my code
export async function searchPosts(query: string) {
return await api.posts
.browse({
fields: 'slug, id, title, excerpt, uuid, feature_image',
limit: config.api.ghost.settings.items_per_page * 2,
include: 'tags',
page: 1,
filter: `excerpt:~'${query}'`
})
.catch(err => {
console.error(err);
});
}
Can you please help? Am I missing something?
Thank you. Best regards