I have multiple domain objects and having one to many, many to many relationships and search data comes from couple of tables and it is always same. I implemented Searchable plugin in my app and able to retrieve results when I have single search field like this:
<g:form url='[controller: "searchable", action: "searchContact"]' id="searchableForm" name="searchableForm" method="get">
<g:textField name="query" value="${params.query}" size="40"/>
<input type="submit" value="Search Contact" />
</g:form>.
But I have multiple text fields, check boxes and g:select boxes to get searchTerm. Based on any one of fields or multiple search selections I have to get search results. How to include all search fields in between and having a single submit button for all the params. Here is my search action code:
def searchContact = {
if (!params.query) {
return [:]
}
try {
String searchTerm = params.query
println searchTerm
return [searchResult: searchableService.search(searchTerm, params)]
} catch (SearchEngineQueryParseException ex) {
return [parseException: true]
}
}
Quick suggestions are appreciated.