Do you want to find authors or do you want to find books with this author?
If you want to find books with this author, you can configure the domain classes as follows:
class Author { String name ... static searchable = { root false } }
this will cause the author to be excluded from searchableService.search(query) -result, and you will find field names such as $/Book/Author/name in your index. (use luke to view your index: http://code.google.com/p/luke/ ).
You can change the name of these fields by setting up the best prefix in your Book class:
class Book { String name Author author ... static searchable = { author component: [prefix: 'author'] } }
this will change the name of the field in the index to bookauthor .
If you now search using searchableService.search(query) , you will find all books in which the book name or author name contains a search query. You can even limit the search to a given author using the syntax authorname:xyz .
If you really want to mix search results, I only know the solution that you already mentioned: mixing both results with your own code, but I think it will be difficult to mix hit counts in a good way.
Update your answer: Here is my pagination code ...
.gsp:
<div class="pagination"> <g:paginate total="${resultsTotal}" params="[q: params.q]"/> </div>
controller:
result = searchableService.search(params.q, params) [ resultList: result.results, resultsTotal: result.total ]
So, if you just combine the results of your two searches and add result.total s, this might work for you.