Last updated by
1 year ago
Page: Searchable Plugin - Quick start, Version:2
Quick start
Install the plugin
JDK 1.5+ users:grails install-plugin searchable
grails install-plugin searchable14
Define Searchable classes
Add a static searchable property to the domain classes you want to be stored in the search index, for example:class Post {
static searchable = true // <-- Make Posts searchable
static hasMany = [comments: Comment]
String category, title, post
User author
Date createdAt
}class Comment {
static searchable = true // <-- Make Comments searchable
static belongsTo = [post: Post]
String comment
Post post
User user
Date createdAt
}class User {
static searchable = true // <-- Make Users searchable
static hasMany = [posts: Post]
String username, password
}Try it!
Fire up your app… during startup the plugin will build the search index all for searchable class instances in your database .Navigate to http://localhost:8080/YOUR-APP-NAME-HERE/searchable, and try a few queries.You just made your domain searchable !Next steps
Hack the controller and view to your own tastes.Find what you're looking for with the simple and powerful search API methods.Customize the mappings between your classes and the search index.See how to manage the index yourself if you need to; normally you do not, since changes made through Hibernate/GORM are mirrored to the index automatically.Override defaults and more with configuration: for example, you could increase the search result page size from 10 to 20.Trouble-shoot problems with the debugging tips and FAQ.Happy searching !