简体   繁体   中英

Grails Searchable Plugin Many-to-Many search

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.

Did you tried this:

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

?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM