Hi I’m trying to implement search functionality using Ghost API and I have this filter title:~'${searchParams}'
working fine. I also want to add authors names to the search. These filters does not work:
authors:~'${searchParams}'
author:~'${searchParams}'
authors.name:~'${searchParams}'
how I would filter the posts by authors or tags that contains searchParams
?
Hey Kate! Welcome to Ghost!
Content API or Admin API? And you’re trying to search for posts?
If ContentAPI, I think you need include=authors on your query string, and you’ll want something like filter=author:[author1,author2]. And of course it needs to be url-encoded. :)
The :~ notation is for matching part of a string. For belonging to a group, you want :[item1,2,3] instead.
One comment: The ContentAPI isn’t really set up for searching, more like filtered retrieval. If you want fuzzy matching or something more sophisticated, you may want to look at how the sodo-search app (it’s in the Ghost monorepo) handles searching. It basically gets everything from the ContentAPI then uses a search package in the browser to actually search it.
1 Like