Grails Searchable Plugin Many-to-Many search

351 Views Asked by At

I have domain class User which has many-to-many relationship to domain class LibraryElement. I am trying to filter all the library elements, with certain text in it, that belong to User. This is how the searchable properties and relationship is defined:

User side:

static searchable = {
    id name: 'userId'
    libraryElements component: true
}

static hasMany = [libraryElements: LibraryElement]

LibraryElement side:

static searchable = {
    users component: true
}

static belongsTo = User
static hasMany = [users: User]

I am trying to execute search like this:

LibraryElement.search("userId:" + userId + " libraryElementName:" + searchWord + "*")

I am getting 0 results even though in database there is a data that should be hit by this search.

1

There are 1 best solutions below

0
On

Did you tried this:

LibraryElement.search(searchWord +" AND userId:userId", params)

?