Grails searchable pluggin gives you capability to add search functionality to your grails project. With this pluggin you can index your domain classes. It is built on the Compass Search Engine Framework and Apache Lucene.
The main advantage I experienced while using lucene indexing for searching is, it is simpler and faster than doing %LIKE% query on relational database. The underline method of tokenizing words and indexing with lucene can be found from here. Here I explain sample codes I used in my maven structured grails project.
Maven dependencies you need.
I assume There is a Domain class ‘Book’ and a Controller ‘BookController’ and a method ‘search’ in BookController class.
This is a part of the list.gsp where the books are listed.
Service classhelpful link