How to prevent App-wide searches with Searchable Plugin?

For my Grails application I am using a search plugin to have a nice "google search".

I followed the instructions and added:

class Address {
    static searchable =true

    Integer id                  
    AddressGroups addressType   
    String briefDescription     
    String company 
}  

      

It works really well. The problem here is that the search bar in my application searches all classes.

I know this is a simple problem. But I haven't found any documentation for this problem. I just want to search for one domain class at a time. Not all classes.

Additional information: Also, I got the user class and the address group class. As you can see, Addressgroups provides an AddressType for an address.

+2


source to share


1 answer


to search for results of only one type, you can add an additional search term "alias: DomainClassName" (this should be specified in a normal query) so it becomes

(searchterm) AND (alias: DomainClassName)



if you wanted this result to be found in address groups as a result, you could define address groups as a component and make address groups a non-root compass object.

class Person {
    AdressGroups addressType
    static searchable = {
        root true
        addressType component: [prefix:'person_']
    }
}
class AdressGroups {
    static searchable = {
        root false
    }
}

      

+3


source







All Articles