Does Keystone have a built in 'Search' functionality?

885 views
Skip to first unread message

Daniel Price

unread,
Mar 27, 2014, 10:22:44 AM3/27/14
to keyst...@googlegroups.com
I'm developing the blog section of a site, and want to implement a search to search within that blog. Does Keystone come with something like that out of the box?

David Vermeir

unread,
Apr 3, 2014, 6:17:33 AM4/3/14
to keyst...@googlegroups.com
It does have a search functionality in the Admin UI part, so maybe you could take a look at that to reverse engineer it.
When defining a list you can even add a 'searchFields' option that defines which fields the Admin UI should search through.

If you want to make something custom, it shouldn't be too hard using something like keystone.list('Post').model.find({ whatever: req.body.search_input }).

joss

unread,
May 23, 2014, 1:33:16 AM5/23/14
to keyst...@googlegroups.com
Hi Daniel,

Keystone is built on Mongoose so you can use any queries they supply, for instance you could search you posts:

var postsQuery = keystone.list('Post').model.find();
  
if (req.query.searchterm) {
  var regex = new RegExp(req.query.searchterm, 'i');
  postsQuery.where( 'name', regex )
}


Reply all
Reply to author
Forward
0 new messages